vb form问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:34:41
设一个工程由两个窗体组成,其名称分别为 Form1 和 Form2,在 Form1 上有一个名称为 Command1
的命令按钮。窗体 Form1 的程序代码如下:
Private Sub Command1_Click()
Dim a As Integer
a = 10
Call g(Form2, a)
End Sub
Private Sub g(f As Form, x As Integer)
y = IIf(x > 10, 100, -100)
f.Show
f.Caption = y
End Sub
运行以上程序,正确的结果是
a Form1 的 Caption 属性值为 100
b Form2 的 Caption 属性值为 -100
c Form1 的 Caption 属性值为 -100
d Form2 的 Caption 属性值为 100

刚学不太懂 有高手帮忙仔细讲解下吗 谢谢了

Private Sub Command1_Click()
Dim a As Integer
a = 10
Call g(Form2, a) '调用g方法
End Sub
Private Sub g(f As Form, x As Integer)
y = IIf(x > 10, 100, -100) '判断x是否大于10,如果大于,则y=100,否则y=-100
f.Show '显示f这个窗体
f.Caption = y '设置f窗体的caption属性为y
End Sub
所以最后选B

Private Sub Command1_Click()
Dim a As Integer
a = 10
Call g(Form2, a) 调用函数:
y = IIf(x > 10, 100, -100)
a=10》y=-100>>退出函数时a=-100
所以选B