运行下列程序,单击窗体显示的结果为( )。 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
举一反三
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 以下VBA程序运行的结果是( ) Public Sub Form_Click() Dim s As Integer s = 0 For i = 1 To 2 s = 1 For j = i To 3 s = s + i * j Next j Next i MsgBox "s=" &; s End Sub A: 11 B: 18 C: 22 D: 7
- 下列程序中 s = s + j 语句共执行了______次。 Dim s As Integer Dim i As Integer, j As Integer For i = 1 To 10 Step 2 For j = 1 To 5 Step 2 s = s + j Next j Next i Print s
- 单击窗体,在窗体上打印数列:2/1 ,3/2 ,5/3 ,8/5 ,13/8 … 的前10项,并求其和,将和保存在变量s中。 Private Sub Form_Click() Dim i%, j%, k%, m As Integer Dim s As Single s = 0 i = 2 'i为分子 j = 1 'j为分母 For k = 1 To 10 s = 【1】 Print i & "/" & j m = j j = i i = 【2】 Next Print s End Sub
- 下列程序的运行结果为( )。 Private Sub Command1_Click() Dim a(5) As String Dim i As Integer For i = 0 To 5 a(i) = i + 1 Print a(i); Next i End Sub