VB指定时间执行事件

来源:百度知道 编辑:UC知道 时间:2024/06/09 05:46:28
我利用timer想让程序运行到指定时间弹出form2,可以实现。但是当我把系统的时间格式由(比如10:20:00)改成(AM 10:20:00)就不行了,请问高手们有没有其他的办法啊!我的代码是:
Private Sub Form_Load()
Timer1.Interval = 300
Label1.Caption = Clear
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Time
If Label1.Caption = "10:20:00" Then
'Unload Me
Form2.Show
End If
End Sub
我的意思是假如两台电脑系统时间的格式设置不同就导致程序不可用!谢谢!

Private Sub Form_Load()
Timer1.Interval = 300
Label1.Caption = Clear
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Time
If CDate(Time) = CDate("11:19:20") Then
'Unload Me
Form2.Show
End If
End Sub

==============================
CDate函数用法如下:
http://baike.baidu.com/view/611252.htm

If Label1.Caption = "10:20:00" Then 改为
If right(Label1.Caption,8) = "10:20:00" Then