在窗体上添加一个文本框Text1和一个命令按钮Command1,然后编写如下事件过程:
Private Sub Command1_Click()
Dim i As Integer, n As Integer
For i = 0 To 50
i = i + 3
n = n + 1
If i > 10 Then Exit For
Next
Text1.Text = Str(n)
End Sub
程序运行后,单击命令按钮,在文本框中显示的值是( )。
Private Sub Command1_Click()
Dim i As Integer, n As Integer
For i = 0 To 50
i = i + 3
n = n + 1
If i > 10 Then Exit For
Next
Text1.Text = Str(n)
End Sub
程序运行后,单击命令按钮,在文本框中显示的值是( )。
举一反三
- 窗体上有一个名为Command1的命令按钮,编写如下事件过程: Private Sub Command1_Click() i = 0 Do While i < 8 For j = 1 To i n = n + 1 Next i = i + 1 Loop Print n End Sub 运行程序,单击命令按钮,则输出结果是______。
- 在窗体上有一命令按钮Command1,其Click事件代码如下: Private Sub Command1_Click() Dim a%, b%, i%, n% For i = 1 To 10 n = InputBox("请输入一个整数", "输入数据框", 2) If n Mod 2 = 0 Then a = a + 1 Else b = b + 1 End If Next i MsgBox ("运行结果a=" & str(a) & ", b=" & str(b)) End Sub
- 在窗体中有1个命令按钮Command1和1个文本框Text1,编写事件代码如下:Private Sub Command1_Click() For i=1 To 4 x=3 For j=1 To 3 For k=1 To 2 x=x+3 Next k Next j Next i Text1.Value=Str(x) End Sub 打开窗体运行后,单击命令按钮,文本框Text1输出的结果是
- 在窗体中有1个命令按钮Command1和1个文本框Text1,编写事件代码如下: Private Sub Command1_Click() x = 3 For i = 1 To 4 x = x + 3 Next i Text1.Value =Str(x) End Sub 打开窗体运行后,单击命令按钮,文本框Textl输出的结果是( )。
- 在窗体上画一个名称为Command1的命令按钮和一个名称为Text1的文本框,然后编写如下事件过程: Private Sub Command1_Click() n =Val(Text1.Text) For i = 2To n For j =2 To sqr(i) Ifi Mod j = 0 Then Exit For Next j If j> Sqr(i) Then Print i Next i End Sub 该事件过程的功能是_____。