用VB作计时器
来源:百度知道 编辑:UC知道 时间:2024/09/28 09:11:19
希望各位朋友能够写的详细些
谢谢
'Form 中放一个Textbox(设置Multiline为True,ScrollBars为2),两个按钮(名字不用改)
'按回车会自动计时和停止。满意就记得追+分呀~~~
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public SStart, SEnd, Stime
Private Sub Command1_Click()
Command1.Enabled = False: Command2.Enabled = True: Command2.Default = True
SStart = GetTickCount
Text1.Text = Text1.Text & "你点击[开始]的时间:" & Now & vbCrLf
End Sub
Private Sub Command2_Click()
SEnd = GetTickCount
Stime = Val(SEnd - SStart)
Text1.Text = Text1.Text & "你点击[停止]的时间:" & Now & vbCrLf & "自点击[开始]以来已经过的时间:" & Stime \ 1000 & "秒" & Stime Mod 1000 & "毫秒" & vbCrLf
End Sub
Private Sub Form_Load()
Command1.Caption = "开始": Command2.Caption = "停止": Command2.Enabled = False: Text1.Text = "": Command1.Default = True
End Sub
告诉我邮箱我给你发来完整版
Dim Text As Integer, js As Double, xj As