单选题 VB
题号 #142627

在窗体上画一个名称为 Text1 的文本框和一个名称为 Commandl 的命令按钮,然后编写如下事件过程:  
Private Commandl_Click()  
 Dim i As Integer, n As Integer  
  For i=0 To 50  
   i = i+3  
   n = n+1  
   If i>10Then Exit For  
 Next  
  Textl.Text=Str(n)  
End Sub  
程序运行后,单击命命令按钮,在文本框中显示的值是( )。

进入在线模考

参考答案

C

答案解析

在此题中要注意Exit For语句,该语句是跳出循环体,变量n记录循环执行次数。由于循环跳出的条件是I>10,而I的步长为3,所以循环只执行了3次。

你可能感兴趣的试题

A.Privale Sub List1_Click()
   Label1.Caption=List1. ListIndex
   List1.Removeltem List1.Text
  End Sub
B.Private Sub List1_Click()   
   Label1.Name=List1. ListIndex   
   List1.RemoveItem List1.Text   
  End Sub  
C.Private Sub List1_Click()
   Label1.Caption=List1.Text
   List1.RemovItem List1.ListIndex
  End Sub
D.Private Sub List1_Click()   
   Label1.Name=List1. Text   
   List1.RemoveItem List1. ListIndex   
  End Sub
找试题 · 找答案 · 找资料 在线模考