>>>考試吧考后首發(fā)2013年3月計算機等考試題答案
例如: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 "運行結(jié)果" + Ucase(ch) + Str(i)
End Sub
結(jié)果:運行結(jié)果C3
、 循環(huán)結(jié)構(gòu)
1、For------Next (循環(huán)次數(shù)的計算)
特例: