Results 1 to 9 of 9

Thread: How to improve this

Threaded View

  1. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: How to improve this

    Try this
    Code:
    Private Sub Timer1_Timer()
    
        Static HH As Long
        Static MM As Long
        Static SS As Long
        Static TS As Long
        
        TS = (TS + 1) Mod 100
        
        If TS = 0 Then
            SS = (SS + 1) Mod 60
            If SS = 0 Then
                MM = (MM + 1) Mod 60
                If MM = 0 Then
                    HH = (HH + 1) Mod 24
                End If
            End If
        End If
    
     
     Label5.Caption = Right("00" & HH, 2) & ":" & _
                      Right("00" & MM, 2) & ":" & _
                      Right("00" & SS, 2) & ":" & _
                      Right("00" & TS, 2)
     
    End Sub
    Last edited by 4x2y; May 17th, 2013 at 06:51 AM. Reason: Change variables declaration to Long instead of Single



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width