help with this crazy timer please...
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
ok so i have a label in a UserControl.

i am having some issues getting to work @ all and display the proper countdown result.
these are the main VARs for the timer to use @ Load_Event
50cc to the one that figures this out and get it working right.
plus if you want to use a BackgroundWorker seeing how main of these timers can be running at once you can.

i am having some issues getting to work @ all and display the proper countdown result.
Code: Select all
Public Class mainTimer
Dim Days As Integer = 0
Dim Hrs As Integer = 0
Dim Mins As Integer = 0
Dim Secs As Integer = 0
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Me.Dispose()
End Sub
Private Sub mainTimer_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
Dim Days As Integer = 0
Dim Hrs As Integer = 0
Dim Mins As Integer = 5
Dim Secs As Integer = 0
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
Try
Timer1.Enabled = True
Timer1.Start()
Catch ex As Exception
End Try
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
If Days > 0 Then
Days = Days - 1
Hrs = 23
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Hrs > 0 Then
Hrs = Hrs - 1
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Mins > 1 Then
Mins = Mins - 1
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Secs > 1 Then
Secs = Secs - 1
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Days = 0 AndAlso Hrs = 0 AndAlso Mins = 0 AndAlso Secs = 0 Then
'set alert types and functions
End If
End Sub
End Class
these are the main VARs for the timer to use @ Load_Event
Code: Select all
can i get any help? Dim Days As Integer = 0
Dim Hrs As Integer = 0
Dim Mins As Integer = 5
Dim Secs As Integer = 0
50cc to the one that figures this out and get it working right.
plus if you want to use a BackgroundWorker seeing how main of these timers can be running at once you can.
Hi,
replace
Hope it helps
replace
Code: Select all
With
Private Sub mainTimer_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
Dim Days As Integer = 0
Dim Hrs As Integer = 0
Dim Mins As Integer = 5
Dim Secs As Integer = 0
Code: Select all
Replace:
Private Sub mainTimer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
Days = 0
Hrs = 0
Mins = 5
Secs = 0
Code: Select all
WithPrivate Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
If Days > 0 Then
Days = Days - 1
Hrs = 23
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Hrs > 0 Then
Hrs = Hrs - 1
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Mins > 1 Then
Mins = Mins - 1
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Secs > 1 Then
Secs = Secs - 1
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
ElseIf Days = 0 AndAlso Hrs = 0 AndAlso Mins = 0 AndAlso Secs = 0 Then
'set alert types and functions
End If
End Sub
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Secs > 0 Then
Secs = Secs - 1
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
Exit Sub
ElseIf Mins > 0 Then
Mins = Mins - 1
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
Exit Sub
ElseIf Hrs > 0 Then
Hrs = Hrs - 1
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
Exit Sub
ElseIf Days > 0 Then
Days = Days - 1
Hrs = 23
Mins = 59
Secs = 59
tmrResult.Text = Days.ToString + ":" + Hrs.ToString + ":" + Mins.ToString + ":" + Secs.ToString
Exit Sub
ElseIf Days = 0 AndAlso Hrs = 0 AndAlso Mins = 0 AndAlso Secs = 0 Then
'set alert types and functions
End If
End Sub
Hope it helps
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo![]()
It would be easier to use a TimeSpan.
Code: Select all
Public Class mainTimer
Dim span As TimeSpan = TimeSpan.Zero
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Me.Dispose()
End Sub
Private Sub mainTimer_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = False
span = TimeSpan.FromMinutes(5)
tmrResult.Text = span.ToString()
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
span -= TimeSpan.FromSeconds(1)
tmrResult.Text = span.ToString()
If span.TotalSeconds = 0 Then
'set alert types and functions
End If
End Sub
End Class
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023