例如:1、if 語句:
Private Sub Form_Click()
Dim x As Integer, y As Integer
Dim z As Single
x = 0.2
y = 1
If (x >= 1) Then
z = Log(x)
ElseIf x >= 0 And x < 1 And y >= 0 Then
z = 2 * x - y
Else
z = Exp(x + y)
End If
Print "z=" + Str(z)
End Sub
結(jié)果: z=-1
2、Select Case語句
Private Sub Form_Click()
Dim ch As String, i As Integer
ch = "c"
Select Case ch
Case "A", "a"
i = 1
Case "B", "b"
i = 2
Case "C", "c"
i = 3
Case "D", "d"
i = 4
Case Else
i = 5
End Select
Print "運(yùn)行結(jié)果" + Ucase(ch) + Str(i)
End Sub
結(jié)果:運(yùn)行結(jié)果C3
② 循環(huán)結(jié)構(gòu)
1、For------Next (循環(huán)次數(shù)的計算)
特例:
相關(guān)推薦:
計算機(jī)等級考試二級VB上機(jī)試題及答案解析(50套)
2011年3月計算機(jī)二級VB筆試試題答案及解析匯總
計算機(jī)等級考試二級VB九套全真模擬試題及答案