vb.net 语法
IF
If intNumber = 1000 Then
MessageBox.Show("'intNumber' is, indeed, 1000!", "Simple If")
ElseIf intNumber = 27 Then
MessageBox.Show("'intNumber' is 27!", "Simple If")
Else
MessageBox.Show("'intNumber' is not 1000!", "Simple If")
End If
单行的if语句 不需要End If 单行的If语句如果需要执行多个操作, 需要用冒号隔开.
不等于的符号 <> 也可以用 If Not strName = "Wendy" Then
-------------------------------------------------------------------------------------------------------------------------------
逻辑操作符写法 And Or
不区分大小写 ToLower toUpper
-------------------------------------------------------------------------------------------------------------------------------
Select Case
Select Case strName.ToLower
Case "eddie","ccc","bbb",
strFavoriteColor = "Passionate Purple"
Case "katelyn"
strFavoriteColor = "Red"
Case Else
'do something here
End Select
For...Next
-------------------------------------------------------------------------------------------------------------------------------
循环
循环 可以指定步长 步长可以为负数--从大到小循环
Do Untile 条件 ' 直到所给的条件满足为止
语句....
Loop
与之相对的是 Do While Loop语句
Until 和 While可以放到Loop之后 这样循环至少执行一次
与Do While Loop 对应的老的形式的循环是 While End While
退出循环 用 Exit For 和 Exit Do来退出循环
退出当前循环,执行下一次 Continue For 和 Continue Do
-------------------------------------------------------------------------------------------------------------------------------
定义数组
Dim strArr(9) As String ' 注意,这儿的9 是 last index,也就是说,数组的长度是10
Array.Sort(strArr) ' 可以使用这个方法对数组排序
Reverse方法可以对数组反向
也可以使用下面的方法定义数组并赋值
Dim strArr2 As String = {"a","b","c"}
-------------------------------------------------------------------------------------------------------------------------------
枚举类型定义 enum
常量 const
结构定义 用 structure
list 用 ArrayList
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------