VB.net的特殊语法(区别于C#.NET)
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)的更多相关文章
- VB.NET与C# 语法区别展示
在学习VB.NET后发现,VB.NET与C#的语法主要的不同在两个部分,这两部分搞通了,那就游刃有余,迎刃而解了.现将其对比总结如下: 一.实体部分 (与VB相比,在C#和VB.NET中,实体的使用很 ...
- C++与Java的语法区别
C++与Java的语法区别 首先,两个大的不同是主函数和怎样编译的不同,接下来是许多小的区别. main 函数C++//自由浮动的函数int main( int argc, char* argv[]) ...
- VB.NET与C# 语法show差异
学习VB.NET后发现,VB.NET与C#的语法基本的不同在两个部分,这两部分搞通了,那就游刃有余,迎刃而解了. 现将其对照总结例如以下: 一.实体部分 (与VB相比.在C#和VB.NET中,实体的使 ...
- Python2和Python3的一些语法区别
Python2和Python3的一些语法区别 python 1.print 在版本2的使用方法是: print 'this is version 2 也可以是 print('this is versi ...
- python2 与 python3 语法区别
python2 与 python3 语法区别 概述# 原稿地址:使用 2to3 将代码移植到 Python 3 几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为 ...
- MySQL与Oracle的语法区别详细对比
MySQL与Oracle的语法区别详细对比 Oracle和mysql的一些简单命令对比在本文中将会涉及到很多的实例,感兴趣的你不妨学习一下,就当巩固自己的知识了 Oracle和mysql的一些简单 ...
- python语法区别
python语法区别: 大小写敏感 (动态语言:python)变量不用声明 p.s: 静态语言(Java)必须声明变量 语句末尾可以不打分号 可以直接进行数学计算 复制.粘贴功能失效,粘贴到别的地方的 ...
- C、C++、Java、go的语法区别
详细C++.Java比较:http://www.cnblogs.com/stephen-liu74/archive/2011/07/27/2118660.html 一.C.C++的区别 在很大程度上, ...
- pyhton2 python3 语法区别
几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为了简化这个转换过程,Python 3自带了一个叫做2to3的实用脚本(Utility Script),这个脚本会 ...
随机推荐
- FORTRAN 90标准函数(一) (转)
符号约定: l I代表整型;R代表实型;C代表复型;CH代表字符型;S代表字符串;L代表逻辑型;A代表数组;P代表指针;T代表派生类型;AT为任意类型. l s:P表示s类型为P类型(任意kind ...
- linux--------------今天又遇到一个奇葩的问题,就是linux文件的权限已经是777了但是还是没有写入权限,按照下面的命令就解决了
查看SELinux状态: 1./usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态 SELinux status: ...
- 第一部分:连接MYSQL数据库代码
<?php $connec=mysql_connect("localhost","root","root") or die(" ...
- 转载 wpf使用经验
转载自 胡庆访[ http://zgynhqf.cnblogs.com/ ] WPF 是一个界面层框架技术,要对 WPF 技术达到熟练运用的程度,需要同时拥有开发和设计两方面的知识.而我作为一名开发人 ...
- 9款一键快速搭建PHP运行环境的好工具
9款一键快速搭建PHP运行环境的好工具 胡倡萌 2011/02/19 网络资源 77,063 1 内容提要: 建立一个PHP网站,首先需要搭建PHP的开发和运行环境,对于PHP初学者也是一个难 ...
- 关于SSIS中解密FTP字符串的方法
FTP(File Transfer Protocol),是文件传输协议的简称.用于Internet上的控制文件的双向传输.同时,它也是一个应用程序(Application).用户可以通过它把自己的PC ...
- openWrt 安装与实践
1. 先装一个编译用的环境, ubuntu 14 2. 在ubuntu里面安装svn, g++, libncurses5-dev git libssl-dev gawk, svn因为openwrt社区 ...
- PROC系列之---/proc/pid/stat
转自: http://blog.csdn.net/zjl_1026_2001/article/details/2294067 /proc/ /stat 包含了所有CPU活跃的信息,该文件中的所有值 ...
- 扩展GridView实现的一个自定义无刷新分页,排序,支持多种数据源的控件TwfGridView
最近项目View层越来越趋向于无刷新化,特别是数据展示方面,还要对Linq有很好的支持.在WebFrom模式的开发中,GridView是一个功能很强大,很常用的控件,但是他也不是完美的,没有自带的无刷 ...
- MVC简单分层思想(连接数据库)
图片内容是所有的包名,文件名. 1.创建(M)模型 package oa.bean; public class User { private String userName; private Stri ...