设有下面程序:
Function F( a As Integer)
b = 0
Static c
b= b + 1
c= c + 2
F= a + b + c
End Function
Private Sub Command1_Click()
Dim a As Integer
a = 2
For i = 1 to 3
Print F(a);
Next i
End Sub
运行上面的程序,单击命令按钮 Command1 ,输出结果为________
Function F( a As Integer)
b = 0
Static c
b= b + 1
c= c + 2
F= a + b + c
End Function
Private Sub Command1_Click()
Dim a As Integer
a = 2
For i = 1 to 3
Print F(a);
Next i
End Sub
运行上面的程序,单击命令按钮 Command1 ,输出结果为________
举一反三
- 阅读程序: Function Fun(a As Integer) Static C b=0:b=b+2:c=c+2 F=a*b*c End Function Private Sub Command1_Click() Dim a As Integer a=2 For i=1 To 2 Print Fun( A: ; B: Next C: End Sub D: 运行上面的程序,单击命令按钮,输出结果为A) 8 16 E: 9 18 F: 10 20 G: 7 14
- 编写如下程序: Private Sub Command1_Click() Dim n As Integer : Static s As Integer For n = 1 To 3 s = s + n Next Print s End Sub 程序运行后,第三次单击命令按钮Command1时,输出结果为
- 以下程序的运行结果是 Sub s1(b() As Integer) For i = 1 To 4 b(i) = 2 * i Next i End Sub Private Sub Command1_Click() Dim a(1 To 4) As Integer For i = 1 To 4 a(i) = i + 5 Next i s1 a() For i = 1 To 4 Print a(i) Next i End Sub
- 在窗体上画一个名称为 Command1 的命令按钮,然后编写下列通用过程和命令按钮的事件过程: Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_Click Dim i As Integer,s As Integer s=0 For i = 1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是
- 运行下列程序,单击窗体显示的结果为( )。 Private Sub Form_Click() Dim a Dim s As Integer, i As Integer a = Array(1, 2, 3) For i = 2 To 0 Step -1 s = s + a(i) * a(i) Next i Print s End Sub