Problem related to the scroll value ?

BarryTang
BarryTang used Ask the Experts™
on
I use vertical scroll bar to scroll through a picture box and fill up the change procedure as follows :

Private Sub VScroll1_Change()
    i = i + 1
    Call proc1
End Sub

But when I click the arrow ( upper or lower arrow ) or click the scroll bar once, it always scroll the value two times ( so call the proc1 two times ). When I put a checking integer i to check, the value of i also increment  twice. However, when I insert a breakpoint at the end of the change procedure, the result return to normal. ( call the proc1 once, i value increment by one )

Does anybody know the reason ?



Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
so I'm guessing that proc1 does something to the min/max/scroll value... ?

Commented:
Put in your H/VScroll event a static variable to avoid cyclic events:

Static VScroll_IP as Boolean

If VScroll_IP then Exit Sub Else VScroll_IP = True

'your code ...

VScroll_IP = False

Commented:
You should use the Value property of the scrollbar instead of 'i'.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
Ignore my first comment, please.

You problem is propably because when you press the mouse button, the Change event is raised. When you release the button, it is raised again, to reflect any changes.

When you use a breakpoint, then the MouseUp-event never occures, so the 2nd Change event doesn't eighter.

You could use this code to make proc1 only called once:

If VScroll1.Value <> VScroll1.Tag Then
VScroll1.Tag = VScroll1.Value
Call proc1
End If

Author

Commented:
regret to tell VirLink and y2ksw that both the method could not work, the situation still the same !
BarryTang,
You have 17 opened questions as of this date.  
I will be posting in each of these questions.  
Please take care of your opened questions older than 30 days by clicking on your logon name link and looking for UnlockedQ or using the links I am providing below.  
Please finalize these within 72 hours or I will ask administration to look into your account at that point.  If you have questions, please ask and I will provide assistance.  

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20187331.html
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20133725.html
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20088012.html
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20083509.html
http://www.experts-exchange.com/Miscellaneous/Games/Q_20382035.html
http://www.experts-exchange.com/Programming/Game_Development/Q_20382294.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20534626.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20521771.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20515842.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20513575.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20493221.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20436510.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20399960.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20395868.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20375410.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20373966.html
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20372811.html

Thank you.
Administrative Action - PAQ'd and points NOT refunded.

SpideyMod
Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial