(21) 设一个工程由两个窗体组成,其名称分别为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
(22) 在窗体上画一个名称为Command1的命令按钮,并编写如下程序:
Private Sub Command1_Click()
Dim x As Integer
Static y As Integer
x=10
y=5
Call f1(x,y)
Print x,y
End Sub
Private Sub f1(ByRef x1 As Integer, y1 As Integer)
x1=x1+2
y1=y1+2
End Sub
程序运行后,单击命令按钮,在窗体上显示的内容是
A) 10 5 B) 12 5 C) 10 7 D) 12 7
(23) 设有如下程序
Option Base 1
Private Sub Command1_Click()
Dim a(10) As Integer
Dim n As Integer
n=InputBox("输入数据")
If n<10 Then
Call GetArray(a,n)
End If
End Sub
Private Sub GetArray(b() As Integer,n As Integer)
Dim c(10) As Integer
j=0
For i=1 To n
b(i)=CInt(Rnd()*100)
If b(i)/2=b(i)\2 Then
j=j+1
c(j)=b(i)
End If
Next
Print j
End Sub