1.创建窗体
在弹出菜单中选择【添加】---->【Windows窗体】,然后输入窗体名(我都用的默认名),单击完成
2.添加控件
在窗体上添加一个Button按钮
3.添加代码
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'1-----------------------if多重判断用例--------------------------
' If CInt(TextBox1.Text) > 5 Then
' MessageBox.Show("你输入的数大于5")
' ElseIf CInt(TextBox1.Text) = 5 Then
' MessageBox.Show("你输入的数等于5")
' Else
' MessageBox.Show("你输入的数小于5")
'
' End If
'2-----------------------select case用例-------------------------
'Dim a As Integer = CInt(TextBox1.Text)
'Select Case a
' Case 1, 3, 5, 7, 9
' MessageBox.Show("你输入的是小于10的单数")
' Case 8 To 12
' MessageBox.Show("你输入的是8到12之间的数")
' Case 13 To 25
' MessageBox.Show("你输入的是13到25之间的数")
' Case 31 To 35, Is > 50
' MessageBox.Show("你输入的是31到35之间的数或大于50的数")
'End Select
'3----------------------for.....next语句用例---------------------
'Dim i, s As Integer
'For i = 0 To 100
' s = s + i
'Next
'MessageBox.Show("累计和为" & (s))
'4----------------------for.....each语句用例---------------------
' Dim i As Integer
' Dim a() As String = {"第二章", "语法学习", "学习"}
' For Each a(i) In a
' MessageBox.Show(a(i))
' Next
'5----------------------Do...Loop循环语句用例---------------------
'Dim i As Integer = 0
'Do While i < 100
' If i Mod 5 = 0 Then
' ListBox1.Items.Add(i)
' End If
' i += 1
'Loop
'6----------------------For...Next循环嵌套用例---------------------
'Dim a(3, 3) As Integer
'Dim i, j As Integer
'For i = 0 To 1
' For j = 0 To 1
' a(i, j) = i + j
' ListBox1.Items.Add("a(" & i & "," & j & ") = " & a(i, j))
' Next j
'Next i
'7----------------------过程调用实例---------------------
'add(100, 200)
'8----------------------函数调用实例---------------------
'If add(TextBox1.Text) Then
' MessageBox.Show("邮箱格式正确!")
'Else
' MessageBox.Show("邮箱格式错误!")
'End If
'================================================================
'201802026
'================================================================
'9----------------------参数传递实例---------------------
'Dim a As Integer = TextBox1.Text
'Dim b As Integer = TextBox2.Text
'add(a, b)
'MessageBox.Show(a & "," & b)
'10----------------------数组参数传递实例-----------------
Dim a(3) As Integer
a(0) = 10 : a(1) = 20 : a(2) = 30
MessageBox.Show(sum(a))
End Sub
End Class