Problem related to the scroll value ?

BarryTang used Ask the Experts™
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 ?

Watch Question

Do more with

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

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

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

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!

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


regret to tell VirLink and y2ksw that both the method could not work, the situation still the same !
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.

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

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