Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vscroll in reverse.

Posted on 2004-10-12
5
Medium Priority
?
378 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 54

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 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1400 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 600 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Suggested Courses

824 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