Trackbar Infinite Loop

ETCorp

New member
Joined
Aug 19, 2009
Messages
2
Programming Experience
5-10
Here is what I want:
- simple trackbar
- numeric box that shows the value of the trackbar
- changes in the trackbar show in the numeric box
- changes in the box are reflected in the trackbar

Implementation:
- I have implemented this as a trackbar with a numeric scroll box below
- I used the ValueChanged event for the trackbar to update the value of the numeric box
- I used the ValueChanged event for the numeric box to update the value of the trackbar

Issue:
This causes an infinite loop where the 2 controls continuosly keep updating each other. I just want this to happen 1 time each way.

I am sure that someone has run into this before. Is there a way to temporarily disable events? Am I using the wrong controls? Is there a different way to approach this?
 
Add a updating flag, like this:
VB.NET:
Update-Events:
If Not Me._updating Then
      Me._updating = True
      theOtherControl.Text/Value = thisControl.Text/Value
      Me._updating = False
End If

Something like this.

Bobby
 
Last edited:
Turns out that this was not the issue. There was an endless loop in another part of my code. The actual issue here was that the compiler was complaining about a NULL object that was being used before being set. I have no idea why this was happening becuase the particular object was set during the parent form load event. I have changed the way that part of this code works anyway, so now its not an issue.

Thanks anyway.
 
Back
Top