VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Counter. If you want to see how much time left to a dead-line, you can use this code.

by RDDFM (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 15th May 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Counter. If you want to see how much time left to a dead-line, you can use this code.

Rate Counter. If you want to see how much time left to a dead-line, you can use this code.



'If you want to see how much time left to a dead-line, you can use this code.
'
'This is code of a form.
'All you need to do:
'Make a form. Put Text1,Text2,text3 (Text fields next to each other); Timer1, Label1, Command1
'Put this code to the Form1
'
Dim s, m, g As Long
Dim t As Long
Dim ss, mm, gg As Long

Private Sub Command1_Click()
t = Text1 * 60 * 60 + Text2 * 60 + Text3
Timer1.Enabled = True
End Sub

Private Sub Form_Load()
Text1 = ""
Text2 = ""
Text3 = ""
Command1.Caption = "START!"
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()

t = t - 1

If t <= 59 Then
Label1.Caption = "00:00:" & Str(t)
End If

If 59 < t < 3600 Then
m = Int(t / 60)
s = t - (m * 60)
Call displayed
Label1.Caption = "00:" & mm & ":" & ss
End If

If t > 3599 Then
g = Int(t / 60 / 60)
m = t - (60 * g * 60)
m = Int(m / 60)
s = t - (60 * m) - (60 * 60 * g)
    
Call displayed

Label1.Caption = gg & ":" & mm & ":" & ss

End If

'Check code
Form1.Print "t = " & t
Form1.Print "g = " & g
Form1.Print "m = " & m
Form1.Print "s = " & s
Form1.Print ""
'End of check code

If t = 0 Then
Timer1.Enabled = False
MsgBox ("Time's up!")
End If


End Sub

Sub displayed()
If s > 9 Then
ss = Str(s)
Else: ss = "0" & Str(s)
End If

If m > 9 Then
mm = Str(m)
Else: mm = "0" & Str(m)
End If

If s = 60 Then ss = "00"
If m = 60 Then mm = "00"

If g > 9 Then
gg = Str(g)
Else: gg = "0" & g
End If

End Sub


Download this snippet    Add to My Saved Code

Counter. If you want to see how much time left to a dead-line, you can use this code. Comments

No comments have been posted about Counter. If you want to see how much time left to a dead-line, you can use this code.. Why not be the first to post a comment about Counter. If you want to see how much time left to a dead-line, you can use this code..

Post your comment

Subject:
Message:
0/1000 characters