Private Sub Timer1_Timer() if...............then <--ผมจะให้คลิกที่ ปุ้มcommand แล้วจับเวลา แต่ถ้าไม่ได้คลิกให้ขึ้นเวลาปกติคับ lblTime.Caption = Format(Time(), "hh:mm:ss") End Sub
ลองดูครับ Dim nTimer As Boolean, StartTime As Double
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load() Timer1.Enabled = True Timer1.Interval = 1 End Sub
Private Sub Command1_Click() If nTimer = True Then nTimer = False StartTime = GetTickCount Else nTimer = True End If End Sub
Private Sub Timer1_Timer() If nTimer = True Then lblTime.Caption = (GetTickCount - StartTime) / 1000 Else lblTime.Caption = Format(Time(), "hh:mm:ss") End If End Sub
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load() Timer1.Enabled = True Timer1.Interval = 1 End Sub
Private Sub Command1_Click() StartTime = GetTickCount If nTimer = True Then nTimer = False Else nTimer = True End If End Sub
Private Sub Timer1_Timer() Dim TotalTimer As Long If nTimer = True Then TotalTimer = GetTickCount - StartTime lblTime.Caption = Format(TotalTimer / 1000 \ 60, "00") & ":" & Format(TotalTimer / 1000 Mod 60, "00") & "." & Format(TotalTimer Mod 1000, "000") Else lblTime.Caption = Format(Time(), "hh:mm:ss") End If End Sub
if command1.caption="Start" then command1.caption="Stop" Timer1.Enabled = True else Command1.Caption="Start" Timer1.Enabled = False End if ======================
จากคุณ
:
duke / Kirati_ul2005@hotmail.com [2006-03-12 15:09:39]