VB相关的两个问题

来源:百度知道 编辑:UC知道 时间:2024/05/07 12:57:27
以下是窗体的Click事件过程及其程序代码:
Private Sub Form_Click()
Dim x As Integer, a As Integer , b As Integer, c As Integer
Dim b1 As Boolean, b2 As Boolean
x=10:a=1:b=2:b1=-5:b2=0
If a<b Then
If b<>3 Then
If Not b1 Then
X=-10
Else
If b2 Then x=-30
x=-50
End if
End if
End if
Print x
End Sub
在程序运行过程中,单击窗体时,程序的输出结果是()
(A) –50 (B) –30 (C) –10 (D) 1

请稍加解释,不然看不懂,不好意思...

语句Print IIf(2,3,4)的输出结果为()
(A) 0 (B) 2 (C) 3 (D) 4

谢谢!

1.A 2.C
Private Sub Form_Click()
Dim x As Integer, a As Integer , b As Integer, c As Integer
Dim b1 As Boolean, b2 As Boolean
x=10:a=1:b=2:b1=-5:b2=0
If a<b Then '正确,到下一句
If b<>3 Then '正确,到下一句
If Not b1 Then 'Not b1 =False,不正确,到Else句
X=-10
Else '跳到这里
If b2 Then x=-30 'b2=0就是false,不执行后面的语句
x=-50 'x=-50,结束判断
End if
End if
End if
Print x '打印x=-50
End Sub

Print IIf(2,3,4)
第一个选项如果是true,就打印第二个数,否则就打印第三个数,而第一个选项是2,只有0才是false,其余都是true,因此打印3