Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrollbar_change and cmdCLEAR_click event problem! 2

Status
Not open for further replies.

LMCRYER

Programmer
Jul 30, 2001
388
0
0
US
I have a program which has a scrollbar in it and a clear button.

Within the scrollbar I have the change event coded so that it will do what it is supposed to do. (simple enough...)

I also have the clear button (cmdCLEAR_click) coded so that it will clean out and re-set everything

My error occurs when I re-set the value of the scrollbar to 0 within the cmdCLEAR_click event - because I am changing the value of the scrollbar, it goes to the scrollbar and
it starts going thru the code in there.

I know this is happening becuase the first part of my code within the scrollbar_change is errorhandling for bad values and it pops an error msg when that occurs.

This error msg is coming in when I am doing the CLEAR event.

What I need to know is - how can I re-set thev alue of the scrollbar iwthin the CLEAR event WIHTOUT tripping the change event of the scrollbar to do its thing?

HELP! Ive been fiddling with this for hours!

lmc
cryerlisa@hotmail.com
 
It seems as if there should be a cleaner solution, but without seeing all the code, you could always set a public boolean variable in the cmdClear_Click() that says don't execute scrollbar_change() event.

For example in the cmdClear_Click:

blnScrollChange = False

In the ScrollBar_Change() event put:

If blnScrollChange = False then Exit Sub

Be careful to reset the blnScrollChange value back to true when appropriate or you'll never execute the change event.
 
I have a very messy way of 'getting around' this problem.
I don't know enough to be able to say if there's a better way!

Public Declare a boolean variable.
Set it to true at the begining of your cmdClear_click() event.

At the begining of your scrollbar_change() event, check this variable to see if it's true or false. If it's true you can exit sub from the scrollbar_change event to prevent it from running. (remember to set it back to false though!)

Hope this helps.
 
That and you scroll bar should never be 0, unless you set your minimum to 0. This may be the issue. Craig, mailto:sander@cogeco.ca
"Procrastination is the art of keeping up with yesterday."
I hope my post was helpful!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top