1:引入命名空间(Imports)

Imports System.Exception
Imports System.Data.SqlClient
Imports System.Security.Cryptography
Imports System.Text.StringBuilder

2:实例化类

Dim myConn As SqlConnection
myConn = New SqlConnection(ConnString)

3:IF THEN ELSE END块

If Not IsPostBack() Then
txtEmployee.Text = ""
txtPassWord.Text = ""
else
  txtEmployee.Text = "
txtPassWord.Text = ""
End If

4:Try catch Fanally End Try块

Try
myConn = New SqlConnection(ConnString)
myConn.Open()Catch ex As Exception
Throw New Exception(ex.Message & "clsDatabaseAccess.GetDataBase()")
Finally
myConn.Close()
myConn = Nothing
End Try

5:Sub块

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not IsPostBack() Then
txtEmployee.Text = ""
txtPassWord.Text = ""
End If Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub

6:函数块(function)

    Private Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim i As Integer
Dim sOutput As New System.Text.StringBuilder(arrInput.Length) For i = To arrInput.Length -
sOutput.Append(arrInput(i).ToString("X2"))
Next
Return sOutput.ToString()
End Function

7:变量定义

        Dim bytMessage As Byte()
Dim bytMD5 As Byte()
Dim strMD5 As String
Dim strPassword As String
Dim Readlen As Integer      '数组定义
Dim tTfile() As String = Split(tfileN.Trim, "\")
Dim MD5 As New System.Security.Cryptography.MD5CryptoServiceProvider

8:数据库连接获取DS方法

WEBConfig中配置数据库连接字符串

<appSettings>
<add key="ConnectionString" value="server=1.1.1.1; database=dbTest;user=test;password=test"></add>
</appSettings>

取得WEbCnfig中配置的特定字符串的值:

Private strConnectString = System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectPassWord")

数据库连接并返回ds:

        Dim myConn As SqlConnection
Dim myDataAdapter As SqlDataAdapter
Dim ds As DataSet Try
myConn = New SqlConnection(ConnString)
myConn.Open() strSql = "select EmployeeManagementID from mstEmployeeBasic where EmployeeCode =" & txtEmployee.Text.Trim().ToString()
myDataAdapter = New SqlDataAdapter(Sql, myConn)
Dim ds As New DataSet myDataAdapter.Fill(ds)
GetDataBase = ds If Not (ds.Tables().Rows.Count > ) Then
txtEmployee.Text = ""
txtPassWord.Text = ""
Else
txtEmployee.Text = ""
End If
Catch ex As Exception
Throw New Exception(ex.Message & "clsDatabaseAccess.GetDataBase()") Finally
myConn.Close()
myConn = Nothing
End Try

9:后台提示信息在前台显示:

Response.Write("<script lanugage='javascript'>alert('パスワードが間違いました。');</script>")

10:后台页面跳转:

Response.Redirect("TestPaperList.aspx?code=" & StrConv(txtEmployee.Text.Trim(), VbStrConv.Narrow) & "")

11:后台取URL传过来的参数的值

            employeecode = Request.QueryString("code")
AdminType = Request.QueryString("type")

12:在Vb.net中 用me代替了this

                Me.txtCode.Text = ""
Me.txtPassword1.Text = ""
Me.txtPassword2.Text = ""

13:类型转换

                intCode = CInt(employeecode.Trim())
intType = CInt(AdminType.Trim)

14:拼接数据库字符串

            strSql = ""
strSql = strSql & "insert into " & vbCrLf
strSql = strSql & " administrator values( " & vbCrLf
strSql = strSql & " <$code> " & vbCrLf
strSql = strSql & " ,'<$password>' " & vbCrLf
strSql = strSql & " ,<$type>) " & vbCrLf strSql = Replace(strSql, "<$code>", code.ToString)
strSql = Replace(strSql, "<$password>", password.Trim.Replace("'", "''"))
strSql = Replace(strSql, "<$type>", type.ToString)

15:For循环块

Dim i As Integer = 0
For i = To dsSelectedEmployee.Tables().Rows.Count -
lstSelected.Items(i).Text = dsSelectedEmployee.Tables().Rows(i)() & " " & dsSelectedEmployee.Tables().Rows(i)()
Next

16:下拉框绑定值

        Dim dsSelectedEmployee As DataSet

        Try
If Me.dlstClass.SelectedIndex <> Then
dsSelectedEmployee = GetAnswerer()
Me.lstSelected.DataValueField = "EmployeeNo"
Me.lstSelected.DataSource = dsSelectedEmployee.Tables()
Me.lstSelected.DataBind()
Dim i As Integer =
For i = To dsSelectedEmployee.Tables().Rows.Count -
lstSelected.Items(i).Text = dsSelectedEmployee.Tables().Rows(i)() & " " & dsSelectedEmployee.Tables().Rows(i)()
Next
Else
Me.lstSelected.Items.Clear()
End If Catch ex As Exception
Response.Write(ex.Message)
End Try

VB.net的特殊语法(区别于C#.NET)的更多相关文章

  1. VB.NET与C# 语法区别展示

    在学习VB.NET后发现,VB.NET与C#的语法主要的不同在两个部分,这两部分搞通了,那就游刃有余,迎刃而解了.现将其对比总结如下: 一.实体部分 (与VB相比,在C#和VB.NET中,实体的使用很 ...

  2. C++与Java的语法区别

    C++与Java的语法区别 首先,两个大的不同是主函数和怎样编译的不同,接下来是许多小的区别. main 函数C++//自由浮动的函数int main( int argc, char* argv[]) ...

  3. VB.NET与C# 语法show差异

    学习VB.NET后发现,VB.NET与C#的语法基本的不同在两个部分,这两部分搞通了,那就游刃有余,迎刃而解了. 现将其对照总结例如以下: 一.实体部分 (与VB相比.在C#和VB.NET中,实体的使 ...

  4. Python2和Python3的一些语法区别

    Python2和Python3的一些语法区别 python 1.print 在版本2的使用方法是: print 'this is version 2 也可以是 print('this is versi ...

  5. python2 与 python3 语法区别

    python2 与 python3 语法区别 概述# 原稿地址:使用 2to3 将代码移植到 Python 3 几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为 ...

  6. MySQL与Oracle的语法区别详细对比

    MySQL与Oracle的语法区别详细对比 Oracle和mysql的一些简单命令对比在本文中将会涉及到很多的实例,感兴趣的你不妨学习一下,就当巩固自己的知识了   Oracle和mysql的一些简单 ...

  7. python语法区别

    python语法区别: 大小写敏感 (动态语言:python)变量不用声明 p.s: 静态语言(Java)必须声明变量 语句末尾可以不打分号 可以直接进行数学计算 复制.粘贴功能失效,粘贴到别的地方的 ...

  8. C、C++、Java、go的语法区别

    详细C++.Java比较:http://www.cnblogs.com/stephen-liu74/archive/2011/07/27/2118660.html 一.C.C++的区别 在很大程度上, ...

  9. pyhton2 python3 语法区别

    几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为了简化这个转换过程,Python 3自带了一个叫做2to3的实用脚本(Utility Script),这个脚本会 ...

随机推荐

  1. 对IOC和DI以及AOP的理解

    为了理解Spring的IoC与DI从网上查了很多资料,作为初学者,下面的描述应该是最详细,最易理解的方式了. 首先想说说IoC(Inversion of Control,控制倒转).这是spring的 ...

  2. css名词解释

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 在Ubuntu 12.04下采用apt-get的方法安装Qt4

    在Ubuntu 12.04下采用apt-get的方法安装Qt4 注:之前发表的一篇博客是采用编译源码的方式安装Qt4,这是很有用的方式,因为源码安装对于所有系统都是通用的,其次,在使用交叉编译器的时候 ...

  4. 目标检测方法总结(R-CNN系列)

    目标检测方法系列--R-CNN, SPP, Fast R-CNN, Faster R-CNN, YOLO, SSD 目录 相关背景 从传统方法到R-CNN 从R-CNN到SPP Fast R-CNN ...

  5. (最重要)学了这么久的编程,你知道byte吗?

    在c#中,Byte b=12; 上面是合法的,因为Byte是一个字节.他的范围是0-255. 如果是 Byte b=4096;这是错的 ,必须加上强制类型转换. 这个小问题,虽然很小但是值得注意.

  6. MATLAB的GUI

    % 常使用的对象查看和设置函数 % .get.set函数 ) % 获得句柄值为0的对象的属性,即显示器对象属性 plot([:]); % 绘制一幅图 title('示例'); % 增加text对象 % ...

  7. C# interface abstract class

  8. Window Azure ServiceBus Messaging消息队列技术系列2-编程SDK入门

    各位,上一篇基本概念和架构中,我们介绍了Window Azure ServiceBus的消息队列技术的概览.接下来,我们进入编程模式和详细功能介绍模式,一点一点把ServiceBus技术研究出来. 本 ...

  9. Android 监听返回键、HOME键

    拦截返回键,HOME键,继承BaseActivity即可 import android.app.Activity; import android.content.BroadcastReceiver; ...

  10. YbSoftwareFactory 代码生成插件【十三】:Web API 的安全性

    ASP.NET Web API 可非常方便地创建基于 HTTP 的 Services,这些服务可以非常方便地被几乎任何形式的平台和客户端(如浏览器.Windows客户端.Android设备.IOS等) ...