BarryTang
asked on
Problem related to the scroll value ?
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 ?
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 ?
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
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'.
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
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
ASKER
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.
https://www.experts-exchange.com/questions/20187331/Problem-related-to-Unknown-token-received-from-SQL-Server.html
https://www.experts-exchange.com/questions/20133725/Access-Foxpro-2-6-free-tables-from-SQL-server-2000.html
https://www.experts-exchange.com/questions/20088012/Problem-related-to-insert-a-group-of-record-to-a-data-file.html
https://www.experts-exchange.com/questions/20083509/Connection-Failure-using-local-harddisk.html
https://www.experts-exchange.com/questions/20382035/How-can-I-extract-a-music-track-in-a-midi-file-by-DirectMusic-in-VB.html
https://www.experts-exchange.com/questions/20382294/How-can-I-extract-a-music-track-in-a-midi-file-by-DirectMusic-in-VB.html
https://www.experts-exchange.com/questions/20534626/DLL-Function-can-run-in-exe-but-fail-to-run-in-VB6-environment.html
https://www.experts-exchange.com/questions/20521771/How-can-I-avoid-the-split-of-word.html
https://www.experts-exchange.com/questions/20515842/Can-I-use-this-DLL-in-VB6.html
https://www.experts-exchange.com/questions/20513575/Problem-related-to-shell-wait.html
https://www.experts-exchange.com/questions/20493221/Problem-related-to-the-scroll-value.html
https://www.experts-exchange.com/questions/20436510/How-can-I-made-a-form-on-top-but-will-disappear-when-switch-to-screen-of-other-windows-task.html
https://www.experts-exchange.com/questions/20399960/How-to-use-a-C-dll-in-a-VB6-program.html
https://www.experts-exchange.com/questions/20395868/How-to-play-a-specific-frequency-of-wave-sound-out.html
https://www.experts-exchange.com/questions/20375410/How-can-I-display-special-characters-in-VB-controls.html
https://www.experts-exchange.com/questions/20373966/How-to-display-musical-note-from-midi-file-in-a-VB-program.html
https://www.experts-exchange.com/questions/20372811/How-to-use-DLL-in-my-VB-program.html
Thank you.
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.
https://www.experts-exchange.com/questions/20187331/Problem-related-to-Unknown-token-received-from-SQL-Server.html
https://www.experts-exchange.com/questions/20133725/Access-Foxpro-2-6-free-tables-from-SQL-server-2000.html
https://www.experts-exchange.com/questions/20088012/Problem-related-to-insert-a-group-of-record-to-a-data-file.html
https://www.experts-exchange.com/questions/20083509/Connection-Failure-using-local-harddisk.html
https://www.experts-exchange.com/questions/20382035/How-can-I-extract-a-music-track-in-a-midi-file-by-DirectMusic-in-VB.html
https://www.experts-exchange.com/questions/20382294/How-can-I-extract-a-music-track-in-a-midi-file-by-DirectMusic-in-VB.html
https://www.experts-exchange.com/questions/20534626/DLL-Function-can-run-in-exe-but-fail-to-run-in-VB6-environment.html
https://www.experts-exchange.com/questions/20521771/How-can-I-avoid-the-split-of-word.html
https://www.experts-exchange.com/questions/20515842/Can-I-use-this-DLL-in-VB6.html
https://www.experts-exchange.com/questions/20513575/Problem-related-to-shell-wait.html
https://www.experts-exchange.com/questions/20493221/Problem-related-to-the-scroll-value.html
https://www.experts-exchange.com/questions/20436510/How-can-I-made-a-form-on-top-but-will-disappear-when-switch-to-screen-of-other-windows-task.html
https://www.experts-exchange.com/questions/20399960/How-to-use-a-C-dll-in-a-VB6-program.html
https://www.experts-exchange.com/questions/20395868/How-to-play-a-specific-frequency-of-wave-sound-out.html
https://www.experts-exchange.com/questions/20375410/How-can-I-display-special-characters-in-VB-controls.html
https://www.experts-exchange.com/questions/20373966/How-to-display-musical-note-from-midi-file-in-a-VB-program.html
https://www.experts-exchange.com/questions/20372811/How-to-use-DLL-in-my-VB-program.html
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.