Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Derek Stone
"Drink wet cement and get really stoned"
Posted (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 by divil
"Drink wet cement and get really stoned"
  • Moderators
Posted

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

Visit...Bassic Software
Posted

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

"Drink wet cement and get really stoned"
Posted

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

"Drink wet cement and get really stoned"
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...