Solved

vscroll in reverse.

Posted on 2004-10-12
5
315 Views
Last Modified: 2008-01-09
The vscrolls scrolling in reverse, can someone help me figure out a way to make it scroll normally uparrow makes a number go up,  downarrow makes the number go down.  i been trying to figure a way around this without using that other control updown in ms common controls 2 6.0 sp4.
0
Comment
Question by:andyakira
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 12294605
Can we have your code in the vscroll control's Change event? I think you just simply write something wrong there...
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 350 total points
ID: 12294938
You just need to subtract the current value of VScroll1 from the Max value like this:

Private Sub Form_Load()
    VScroll1.Min = 0
    VScroll1.Max = 100
    VScroll1_Change
End Sub

Private Sub VScroll1_Change()
    Label1.Caption = VScroll1.Max - VScroll1.Value
End Sub
0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 150 total points
ID: 12295350
OK. You have assigned large points, so I'm going to give you a large answer.

If you already have a project with vertical scroll bars, and would like to change their direction, you can subtract Value from Max, but this means you have to
change every line in your code where you referenced Value property.

Alternative is to create your own ActiveX control which will behave just like VScrollBar but in reversed direction, and replace your old VScrollBar with it.
Here's how to do it:

 - start New ActiveX Control  project
 - change project's name to RVSB                          (Reversed Vertical Scroll Bar)
 - change control's name to VScrollReversed
 - create vertical scroll bar control and leave its original name (VScroll1)
 - press F7 and
 - paste this code:
'------------------------------------------------------------
Public Event Change()
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public Event KeyPress(KeyAscii As Integer)
Public Event KeyUp(KeyCode As Integer, Shift As Integer)
Public Event Scroll()

Private Sub UserControl_Initialize()
    VScroll1.Top = 0
    VScroll1.Left = 0
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    VScroll1.Max = PropBag.ReadProperty("Max")
    VScroll1.Enabled = PropBag.ReadProperty("Enabled")
    VScroll1.LargeChange = PropBag.ReadProperty("LargeChange")
    VScroll1.Min = PropBag.ReadProperty("Min")
    VScroll1.MouseIcon = PropBag.ReadProperty("MouseIcon")
    VScroll1.MousePointer = PropBag.ReadProperty("MousePointer")
    VScroll1.RightToLeft = PropBag.ReadProperty("RightToLeft")
    VScroll1.SmallChange = PropBag.ReadProperty("SmallChange")
    VScroll1.Value = PropBag.ReadProperty("Value")
End Sub

Private Sub UserControl_Resize()
    VScroll1.Width = UserControl.Width
    VScroll1.Height = UserControl.Height
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    PropBag.WriteProperty "Max", VScroll1.Max
    PropBag.WriteProperty "Enabled", VScroll1.Enabled
    PropBag.WriteProperty "LargeChange", VScroll1.LargeChange
    PropBag.WriteProperty "Min", VScroll1.Min
    PropBag.WriteProperty "MouseIcon", VScroll1.MouseIcon
    PropBag.WriteProperty "MousePointer", VScroll1.MousePointer
    PropBag.WriteProperty "RightToLeft", VScroll1.RightToLeft
    PropBag.WriteProperty "SmallChange", VScroll1.SmallChange
    PropBag.WriteProperty "Value", VScroll1.Value
End Sub



Private Sub VScroll1_Change()
    RaiseEvent Change
End Sub

Private Sub VScroll1_KeyDown(KeyCode As Integer, Shift As Integer)
    RaiseEvent KeyDown(KeyCode, Shift)
End Sub

Private Sub VScroll1_KeyPress(KeyAscii As Integer)
    RaiseEvent KeyPress(KeyAscii)
End Sub

Private Sub VScroll1_KeyUp(KeyCode As Integer, Shift As Integer)
    RaiseEvent KeyUp(KeyCode, Shift)
End Sub

Private Sub VScroll1_Scroll()
    RaiseEvent Scroll
End Sub

Public Property Get Enabled() As Boolean
    Enabled = VScroll1.Enabled
End Property

Public Property Let Enabled(ByVal vNewValue As Boolean)
    VScroll1.Enabled = vNewValue
End Property

Public Property Get LargeChange() As Integer
    LargeChange = VScroll1.LargeChange
End Property

Public Property Let LargeChange(ByVal vNewValue As Integer)
    VScroll1.LargeChange = vNewValue
End Property

Public Property Get Max() As Integer
    Max = VScroll1.Max
End Property

Public Property Let Max(ByVal vNewValue As Integer)
    VScroll1.Max = vNewValue
End Property

Public Property Get Min() As Integer
    Min = VScroll1.Min
End Property

Public Property Let Min(ByVal vNewValue As Integer)
    VScroll1.Min = vNewValue
End Property

Public Property Get MouseIcon() As StdPicture
    Set MouseIcon = VScroll1.MouseIcon
End Property

Public Property Set MouseIcon(ByVal vNewValue As StdPicture)
    Set VScroll1.MouseIcon = vNewValue
End Property

Public Property Get MousePointer() As Integer
    MousePointer = VScroll1.MousePointer
End Property

Public Property Let MousePointer(ByVal vNewValue As Integer)
    VScroll1.MousePointer = vNewValue
End Property

Public Property Get RightToLeft() As Boolean
    RightToLeft = VScroll1.RightToLeft
End Property

Public Property Let RightToLeft(ByVal vNewValue As Boolean)
    VScroll1.RightToLeft = vNewValue
End Property

Public Property Get SmallChange() As Integer
    SmallChange = VScroll1.SmallChange
End Property

Public Property Let SmallChange(ByVal vNewValue As Integer)
    VScroll1.SmallChange = vNewValue
End Property

Public Property Get Value() As Integer
    Value = VScroll1.Max - VScroll1.Value
End Property

Public Property Let Value(ByVal vNewValue As Integer)
    VScroll1.Value = VScroll1.Max - vNewValue
End Property
'----------------------------------------------------------------

 - compile this to RVSB.OCX
 - Register this new control:          Start->Run, Type:    Regsvr32 C:\Temp\RVSB.OCX

How to use it:
 - Start new Standard EXE
 - Project->Components, find RVSB and enable it
 - Now you should be able to use it same as VScroll, but with reversed direction
0
 

Author Comment

by:andyakira
ID: 12303183
i split points, idlemind(350) and rckovi(150) because both were great solutions, idle minds solution was must faster and thats what im using right now, thanks guys.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 12305372
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now