You are on page 1of 2

VISUAL BASIC 6.

0 ³TIMER´ Private Declare Sub Sleep lib "kernel32" (ByVal dwMilliseconds as long) 'Command Click Dim lngLoopCntr as long Dim lngMilliSecs as Long lngLoopCntr=0 ' although it initializes to 0 , but it is a gud practise to initialize variable lngMilliSecs = 10000 ' 10 Seconds Do While True Sleep 10 lngLoopCntr=lngLoopCntr + 10 if lngLoopCntr > lngMilliSecs then exit Do Loop Msgbox "Done" 'Code Ends :surprised

³Timer´ Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
1. 2. 3. 4. 5. 6. 7. 8. 9. Private Sub Form_Load() Timer1.Interval = 1000 Label1.Caption = "100" End Sub Private Sub Timer1_Timer() if label1.caption = 0 then timer1.enabled = false msgbox ("100 secs is up")

10. else 11. Label1.Caption = label1.caption - 1 12. end if 13. End Sub

Private Sub Form_Load() Text1.Caption = time for x = 1 to 10000 Print "Frost" next Text2.Caption = time Timer1.Interval = 1 Label1.Caption = "" End Sub Private Sub Timer1_Timer() Label1.Caption = Time End Sub Private Sub cmdGo_Click() Dim fields() As String Dim hours As Long

m_StopTime) DateAdd("s". minutes.Dim minutes As Long Dim seconds As Long fields = Split(txtDuration. m_StopTime) DateAdd("n". the code disables the timer and maximizes the form to get your attention. Private Sub tmrWait_Timer() Dim time_now As Date Dim hours As Long Dim minutes As Long Dim seconds As Long time_now = Now If time_now >= m_StopTime Then Me.Enabled = True End Sub When the timer fires. and seconds remain and displays those values. ":") hours = fields(0) minutes = fields(1) seconds = fields(2) m_StopTime m_StopTime m_StopTime m_StopTime = = = = Now DateAdd("h".minutes * 60 hours = minutes \ 60 minutes = minutes . the code determines how many hours.hours * 60 lblRemaining. hours. Format$(seconds. m_StopTime) minutes = seconds \ 60 seconds = seconds .Caption Format$(hours) & Format$(minutes. minutes.Caption = "0:00:00" Else seconds = DateDiff("s". m_StopTime) tmrWait.WindowState = vbMaximized tmrWait. time_now. seconds. it checks the current time. End If End Sub = _ ":" & _ "00") & ":" & _ "00") . If the stop time has not arrived.Text.Enabled = False lblRemaining. If the stop time has arrived.