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. JavaScricp

    常用对话框 1.alert(""):警告对话框,作用是弹出一个警告对话框 2.confirm(""):确定对话框,弹出一个带确定和取消按钮的对话框——确定返回t ...

  2. Linux启用和配置Java

    Firefox 在安装 Java 平台时,Java 插件文件将作为该安装的一部分包含在内.要在 Firefox 中使用 Java,您需要从该发行版中的插件文件手动创建符号链接指向 Firefox 预期 ...

  3. Tomcat源码导入eclipse的步骤

    Tomcat源码导入eclipse 一.下载源码 1.  进入Apache 官网:http://tomcat.apache.org/ 2.  在左边侧选择要下载的源码的版本. 3.  或者直接通过Ar ...

  4. Spring学习笔记之一----基于XML的Spring IOC配置

    1. 在spring配置文件中,如果对一个property进行直接赋值,可使用<value>元素,spring负责将值转化为property指定的类型:也可以直接在property元素上使 ...

  5. Highcharts使用教程(1):制作简单图表

    今天我们要使用JavaScript图表Highcharts制作简单的柱形图,我们已经安装好Highcharts,让我们开始制作图表吧. 步骤一 在网页中添加一个div.设置id,设置图表长.高.代码如 ...

  6. 省市联动sql脚本

    create database ProCityData use Procitydata --创建Province(省表) create table Province ( ProID int prima ...

  7. [To do]Appx Package installed, can't start at first time

    When installed partition tool & mkrcvcd as windows store app. it can't start at first time. the ...

  8. animate动画jquery

    <script> $(".change").animate({height:"hide",width:"300px"},&quo ...

  9. python学习之网页数据获取

    由于需要学习机器学习的内容,了解到python在机器学习中使用很方便,开始学习之,机器学习目前主要在学<机器学习实战>这本书.python是在MOOC中学习<用python玩转数据& ...

  10. NOIP 2014 Day2 T1 无线网络发射器

    #include<iostream> #include<cmath> #include<cstdlib> #include<cstdio> #inclu ...