在窗体上画1个名称为Command1的命令按钮,1个名称为Label1的标签,然后编写如下事件过程: Private Sub Command1_Click() Dim n As Integer, t As Integer n = 1: t =

admin2020-07-22  16

问题 在窗体上画1个名称为Command1的命令按钮,1个名称为Label1的标签,然后编写如下事件过程:
Private Sub Command1_Click()
   Dim n As Integer, t As Integer
   n = 1: t = 1
   Do
      n = n + 1
      t = t * n
   Loop Until n > 4
   Label1.Caption = t
End Sub
程序运行后,单击命令按钮Command1,则标签中显示的内容是

选项 A、1
B、2
C、24
D、120

答案D

解析 当n=1时,执行循环内程序,n=1+1=2,t=1*2=2;当n=2,继续执行循环内程序,n=2+1=3,t=2*3=6;当n=3时,执行循环内程序,n=3+1=4,t=6*4=24;当n=4时,执行循环内程序,n=4+1=5,t=24*5=120,退出循环。故选择D项。
转载请注明原文地址:https://kaotiyun.com/show/XfHp777K
0

随机试题
最新回复(0)