Solved

vscroll in reverse.

Posted on 2004-10-12
5
344 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 50

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 64
Spell Check in VB6 13 126
converting visio 2010 to powerpoint 2010  - formatting issues 5 92
Send outlook email from VBS Script 2 42
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

808 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