VB时钟未解决

来源:百度知道 编辑:UC知道 时间:2024/05/09 14:27:07
VB一个工程FORM1中 一个时钟控件timer 两个按键控件command1 command2 怎样可以用时钟控制command1自动运行 请写出代码.....注:只运行一次

方法有几种,这个最简单的:

Private mSc As Integer

Private Sub Command1_Click()
MsgBox "哈哈~~程序运行啦~~~", vbInformation
End Sub

Private Sub Form_Load()
Timer1.Enabled = True '激活时钟
Timer1.Interval = 5000 '设置时间(1000=1秒)

'计时效果--------------------------------
Timer2.Enabled = True
Timer2.Interval = 1000
mSc = 0
Command1.Caption = mSc
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = False
Timer2.Enabled = False
'5秒后自动运行 Command1
Command1_Click
mSc = 0
End Sub

Private Sub Timer2_Timer()
mSc = mSc + 1
Command1.Caption = mSc
End Sub

搞定,给分 :)))