祁阳最新在售楼盘:请教VB如何在状态栏显示计时器

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 20:10:29
VB初学者,我想在窗体的状态栏上显示计时,就像秒表一样,不知道如何实现?希望有具体的代码,谢谢
我不是想显示系统时间,而是想做个计时功能,要从00:00:00开始

'本页中看到的反杠是生成此网页时系统加上的,源代码中无此反杠
\'Timer1的Interval设置为1000
Dim h, m, s

Private Sub Form_Load()
h = Hour(Now)
m = Minute(Now)
s = Second(Now)

End Sub

Private Sub Timer1_Timer()
If (Hour(Time) - h) <= 9 Then
hh = \"0\" & (Hour(Time) - h)
End If
If (Minute(Time) - h) <= 9 Then
mm = \"0\" & (Minute(Time) - h)
End If
If (Second(Time) - h) <= 9 Then
ss = \"0\" & (Second(Time) - h)
End If

StatusBar1.SimpleText = hh & \":\" & mm & \":\" & ss
End Sub

代码不多

状态栏 : StatusBar1(启用此控件,需要加载VB企业版控件)
Timer控件: Timer1

Timer1的Interval设置为1000,Enable为True
StatusBar1的Style设置为 1-sbrSimple

代码:

Private Sub Timer1_Timer()
StatusBar1.SimpleText = Time '在状态栏StatusBar1显示系统时间
End Sub