Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to code the form to scroll? 1

Status
Not open for further replies.

ii128

Programmer
May 18, 2001
129
US
Does any one knows how to code the form to scroll? Do I need to add a scroll bar on the form and how can I make the scroll bar to scroll when I make the form smaller and larger?

Many thanks
 
This should get you started:

Private Sub Form_Load()
VScroll1.Max = Me.Height
VScroll1.Value = 0

End Sub

Private Sub Form_Resize()
VScroll1.Top = Me.Top
VScroll1.Height = Me.Height
End Sub

Private Sub VScroll1_Scroll()
Me.CurrentX = 10
Me.CurrentY = VScroll1.Max - VScroll1.Value
Me.Refresh
Print VScroll1.Value

End Sub


Notice you can change the .Min and .Max properties of VScroll1, use this to your advantage instead of trying to play with erroneous numbers. This also goes for progress bars, BTW.

Good luck!

-Mike Difference between a madman and a genius:
A madman uses his genius destructively,
A genius uses his madness constructively.
 
copy the blue text and save it as a .FRM file
add it to a blank project as an existing form.

I used similar on a scrolling splash screen, maybe it will give you the idea you need. I have also incorporated the resize of the form/frame. Whatever size you state the form to be the scrollbar, which is not really necesary, will stick to the right and fill the height and the frame will fill the width.

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 345
ClientWidth = 3510
LinkTopic = "Form1"
ScaleHeight = 3150
ScaleWidth = 3510
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 3255
Left = 0
TabIndex = 1
Top = 3240
Width = 3135
End
Begin VB.Timer Timer1
Interval = 100
Left = 0
Top = 0
End
Begin VB.VScrollBar VScroll1
Height = 3135
Left = 3240
Max = 100
TabIndex = 0
Top = 0
Width = 255
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
VScroll1.Top = 0
VScroll1.Left = Form1.Width - 380
VScroll1.Height = Form1.Height - 400
Frame1.Width = Form1.Width - 500
End Sub
Private Sub Form_Resize()
VScroll1.Top = 0
VScroll1.Left = Form1.Width - 380
VScroll1.Height = Form1.Height - 400
Frame1.Width = Form1.Width - 500
End Sub
Private Sub Timer1_Timer()
If VScroll1.Value < VScroll1.Max Then
VScroll1.Value = VScroll1.Value + 1
Frame1.Top = Frame1.Top - 70
Else
Timer1.Interval = 0
End If
End Sub


If you want me for anything else just scream. DeltaFlyer
The Only Programmer To Crash With Style. LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top