单选题
设窗体上有一个标签Label1和一个计时器Timer1,Timer1的Interval属性被设置为1000,Enabled属性被设置为True。要求程序运行时每秒在标签中显示一次系统当前时间。以下可以实现上述要求的事件过程是______。
A.Private Sub Timer 1_Timer() Label1.Caption=True End Sub
B.Private Sub Timer 1_Timer() Label1.Caption=Time$ End Sub
C.Private Sub Timer 1_Timer() Label1.Interval=1 End Sub
D.Private Sub Timer 1_Timer() For k=1 To Timer1.Interval Label1.Caption=Timer Next K End Sub
A
B
C
D
【正确答案】
B
【答案解析】
[考点] 计时器和Timer$函数 [解析] 计时器控件用以实现在规则的时间间隔触发其Timer事件,执行有关事件过程代码,来完成对应功能。Interval属性用于设置触发计时器的Timer事件的时间间隔,单位为毫秒,值为0时计时器不启用。Enabled属性控制计时器是否开始启用,True为启用,False为不启用。调用Time$函数将返回系统当前时间。 要实现本题功能需在计时器的Timer事件过程中,执行将Time$函数返回值赋给标签Caption属性的语句。
提交答案
关闭