Real Software Forums
http://forums.realsoftware.com/

Scrollbar Navigation Question
http://forums.realsoftware.com/viewtopic.php?f=1&t=47926
Page 1 of 1

Author:  mikecotrone [ Mon May 20, 2013 8:21 am ]
Post subject:  Scrollbar Navigation Question

Hi,

I am new to Scrollbars and I am implementing them into a test app I am writing. What is the best style to use when writing "if" statements to recognize when a user is scrolling Up or Down (Vertical Scroll example)?

I have been trying to use the following code which isn't working since it never leaves the first if block.

Sub ValueChanged()
dim LastValue as integer

if me.value > LastValue-1 then
LeftRulerCanvas1.Top = LeftRulerCanvas1.Top - Scrollunit
CampusMapCanvas.Top = CampusMapCanvas.Top - Scrollunit
LastValue = Me.value
elseif me.value < LastValue+1 then
LeftRulerCanvas1.Top = LeftRulerCanvas1.Top + Scrollunit
CampusMapCanvas.Top = CampusMapCanvas.Top + Scrollunit
LastValue = Me.value
end if

End Sub


Thank you in advance!

Author:  DaveS [ Mon May 20, 2013 9:00 am ]
Post subject:  Re: Scrollbar Navigation Question

Move DIM LastValue OUT of that procedure. Put it in a Module.

It needs to be in a scope that is not the same as the procedure itself

otherwise it gets reset to ZERO every time ValueChanged is called... so me.value is ALWAYS greater than -1

Author:  mikecotrone [ Mon May 20, 2013 9:04 am ]
Post subject:  Re: Scrollbar Navigation Question

DaveS wrote:
Move DIM LastValue OUT of that procedure. Put it in a Module.

It needs to be in a scope that is not the same as the procedure itself

otherwise it gets reset to ZERO every time ValueChanged is called... so me.value is ALWAYS greater than -1


:mrgreen: Thanks Dave!

I deleted the DIM statement and just made a property of that canvas object. It worked and thanks again!

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/