阅读程序: Option Base 1 Sub P(b() As Integer) For i=1 To 4 b(i)=2*i Next i End Sub Private Sub Form_Click() Dim a(4)As Integer For i=1 To 4 a(i)=i+4 Next i P a For i=1 To 4 Print a(i) Next i End Sub 运行上面的程序,单击窗体,输出结果为
A: 2 4 6 8
B: 5 6 7 8
C: 10 12 14 16
D: 4 8 12 16
A: 2 4 6 8
B: 5 6 7 8
C: 10 12 14 16
D: 4 8 12 16
举一反三
- 阅读程序: Sub subP(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 a (1)=5 a (2)=6 a (3)=7 a (4)=8 subP a() For i=1 To 4 Print a(i) Next i End Sub运行以上程序,单击命令按钮,输出结果为______ 。 A.2 4 6 8 B.5 6 7 8 C.10 12 14 16 D.出错
- 以下程序的运行结果是 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
- Public Sub Proc(a%( )) Static i% Do a(i) = a(i) + a(i + 1) i = i + 1 Loop While i < 2 End Sub Private Sub Command1_Click( ) Dim m%, i%, x%(10) For i = 0 To 4: x(i) = i + 1: Next i For i = 1 To 2: Call Proc(x): Next i For i = 0 To 4: Print x(i);: Next i End Sub A: 3 4 7 5 6 B: 3 5 7 4 5 C: 2 3 4 4 5 D: 4 5 6 7 8
- 下列代码执行的结果是( )。 Private Sub Form_Click() Dim a(5) Dim i as Integer For i = 1 To 5 <br/>a(i) = i + 2 Next i Print a(4) End Sub A: 6 B: 8 C: 24 D: 2
- 在窗体上画一个名为Command1的命令按钮,然后编写如下代码: Option Base 1 Private Sub Command1_ Click() Dim arr(4, 4) For i = 1 To 4 For j = 1 To 4 arr(i, j) = (i - 1) * 3 + j Next j Next i For i = 1 To 2 For j = 1 To 2 Print arr(i, j) Next j Next i End Sub程序运行后,单击命令按钮,输出结果为______ 。 A: 3 4 6 7 B: 7 8 10 11 C: 1 2 4 5 D: 8 9 12 13