• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

vscroll in reverse.

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.
2 Solutions
Ryan ChongCommented:
Can we have your code in the vscroll control's Change event? I think you just simply write something wrong there...
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
End Sub

Private Sub VScroll1_Change()
    Label1.Caption = VScroll1.Max - VScroll1.Value
End Sub
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
andyakiraAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now