我加入了一个时间控件TIMER1 一个LABEL1 我想打开这个FORM就可以看到系统时间。
我的代码是这么写的
Private Sub Label1_click()
Label1 = Time
End Sub
写的时候我就注意到了这是个CLICK事件,运行的时候果然是要点击一下才能显示出来。
想请问大家,如何编写?
我的代码是这么写的
Private Sub Label1_click()
Label1 = Time
End Sub
写的时候我就注意到了这是个CLICK事件,运行的时候果然是要点击一下才能显示出来。
想请问大家,如何编写?
timer控件是一个定时器,并不是必须有timer控件才能看时间。
你可以写在 timer1_timer()事件里面做个会走的时钟。
不需要点击按钮去触发事件然后再来显示时间。
您们能不能给我完整的一段代码呢?
这么写
Private Sub Form_Load()
Label1.Caption = Time
End SubLABEL里头的时间就定在了我打开FORM的那一瞬间了。
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 500
End SubPrivate Sub Timer1_Timer()
Label1.Caption = Now
End Sub
Timer1.Enabled = True
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
Label1.Caption = Time$
End Sub
Timer1.Enabled = True
Timer1.Interval = 1000
Label1.Caption = Time$ '在Form_Load就要加上,否则你要等1秒后Label才会开始跑
End SubPrivate Sub Timer1_Timer()
Label1.Caption = Time$
End Sub