rosshodges Posted December 20, 2002 Posted December 20, 2002 (edited) Private Sub ResetNumber() If NumericUpDown1.Value = 23 And NumericUpDown2.Value = 59 And NumericUpDown3.Value = 58 Then NumericUpDown1.Value = 0 NumericUpDown2.Value = 0 NumericUpDown3.Value = 0 End If End Sub i was getting an error when puting my count down timer to 23:59:59 so i made this code but it doesnt work any ideas? Ross Edited December 20, 2002 by Derek Stone Quote "Drink wet cement and get really stoned"
Moderators Robby Posted December 20, 2002 Moderators Posted December 20, 2002 It should work, what is the error message? Where are you calling the ResetNumber() from? Quote Visit...Bassic Software
rosshodges Posted December 20, 2002 Author Posted December 20, 2002 (edited) Calling I have have this code Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged Mydisplay() ResetNumber() If NumericUpDown2.Value > 59 Then NumericUpDown3.Value += 1 NumericUpDown2.Value = 0 'That as you can see makes the next NumericUpDown go up by 'one(its a count down timer HH:mm:ss but when it gets put up to '23:59:59 It doesnt no what to do and gives me an error. So i 'tried this Private Sub ResetNumber() If NumericUpDown1.Value = 23 And NumericUpDown2.Value = 59 And NumericUpDown3.Value = 59 Then NumericUpDown1.Value = 0 NumericUpDown2.Value = 0 NumericUpDown3.Value = 0 But it totally un does what I have done before! Edited December 20, 2002 by divil Quote "Drink wet cement and get really stoned"
Moderators Robby Posted December 20, 2002 Moderators Posted December 20, 2002 the problem is that the ValueChanged event is calling ResetNumber(), then when this function changes the value of the numberUpDown the ValueChanged event is triggeres again, you probably get stuck in an endless loop. try using a different event than the ValueChanged Quote Visit...Bassic Software
rosshodges Posted December 20, 2002 Author Posted December 20, 2002 Any ideas what i can change it to? Or the only thing i am trying to do is stop the error appearing when it reaches the limit of 23:59:59 can you think of a way without using Resetnumber()? Regards, Ross Quote "Drink wet cement and get really stoned"
Moderators Robby Posted December 20, 2002 Moderators Posted December 20, 2002 Resetnumber is fine, just not where it's being called from. If you're using a timer, call it from the Timer_Tick event Quote Visit...Bassic Software
rosshodges Posted December 20, 2002 Author Posted December 20, 2002 Any ideas what i can change it to? Or the only thing i am trying to do is stop the error appearing when it reaches the limit of 23:59:59 can you think of a way without using Resetnumber()? Regards, Ross Quote "Drink wet cement and get really stoned"
dejota6 Posted December 26, 2002 Posted December 26, 2002 I agree with Robby, by just changing the location of where the function is called from will fix it. Resetnumber is fine, just not where it's being called from. If you're using a timer, call it from the Timer_Tick event If you absolutely are intent are leaving it similar to what you have, you could set up some flags that once it runs through the first time, the Resetnumber won't be called again until a later time. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.