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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Scroll Bars on Large Forms 1

Status
Not open for further replies.

crowan

Programmer
Jun 6, 2001
1
0
0
US
I am a total noive with VB (I'm using VB 6). I have a form that needs a number of data entry fields added to it, but I do not have room on the screen to add them with the size limitations that are on the form. I am trying to figure out how to add scroll bars onto the existing form that would allow me to scroll up and down on the whlole form. Any help or direction is much appreciated.
 
The way this is usually handled is by separating the data entry fields into logical groups and placing them onto separate tabs of a tab control.

For example, open Word and go to Tools->Options to see how they organize a great many things into one form.

If you really need to scroll a form, one common approach is to place your controls onto a picture box, then use a vertical scroll bar control to set the picture box's .Top property.
 
this code worked great for my form that needed a vert scroll

Dim VPos As Integer

Private Sub VScroll1_Change()
Call ScrollForm(0)
End Sub

Private Sub VScroll1_Scroll()
Call ScrollForm(0)
End Sub

Public Sub ScrollForm(Direction As Byte)
Dim ctl As Control

'Scroll Vertically
If Direction = 0 Then
For Each ctl In Me.Controls
'Make sure it's not a ScrollBar
If Not (TypeOf ctl Is VScrollBar) Then
'If it's a Line then
If TypeOf ctl Is Line Then
ctl.Y1 = ctl.Y1 + VPos - VScroll1.Value
ctl.Y2 = ctl.Y2 + VPos - VScroll1.Value
Else
ctl.Top = ctl.Top + VPos - VScroll1.Value
End If
End If
Next
VPos = VScroll1.Value
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top