?
Solved

Scrollbar

Posted on 1998-06-04
3
Medium Priority
?
272 Views
Last Modified: 2010-05-03
I need help to make the form height more than the screen height and use scrollbar to scroll through the form.
0
Comment
Question by:mathiv
  • 2
3 Comments
 
LVL 1

Expert Comment

by:JayMerritt
ID: 1462545
Break your long form up into multiple forms, each the desired height for presentation.

Use the scroll bar to SHOW the previous or next form.

0
 
LVL 6

Accepted Solution

by:
clifABB earned 150 total points
ID: 1462546
Basically, you don't really want the form to be bigger than the screen (you might think you do, but you don't).

What you want to do is place a picturebox on your form.  Size it to the maximum size you will need.  Set the BorderStyle property to False.  Move all the controls that are on the form (except the picturebox, of course) to the picturebox.
Now, add a scrollbar to the form and align it next to the picturebox.

In the form's resize event, place this code:
Private Sub Form_Resize()

  VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight
  VScroll1.Max = Picture1.Height - Me.ScaleHeight
  If VScroll1.Max < 0 Then
    VScroll1.Max = 0
  End If
  VScroll1.LargeChange = Me.ScaleHeight
  VScroll1.SmallChange = Me.ScaleHeight / 10
End Sub

In the scrollbar's change event, place this code:
Private Sub VScroll1_Change()

  Picture1.Top = VScroll1.Value * -1
End Sub

Note:  The above code will work for vertical only (which is what you requested).  To add horizontal scrolling, add a horizontal scrollbar to the form.
Add the following code to the form load event:
Private Sub Form_Resize()

  VScroll1.Move Me.ScaleWidth - VScroll1.Width, 0, VScroll1.Width, Me.ScaleHeight - HScroll1.Height
  VScroll1.Max = Picture1.Height - Me.ScaleHeight
  If VScroll1.Max < 0 Then
    VScroll1.Max = 0
  End If
  VScroll1.LargeChange = Me.ScaleHeight
  VScroll1.SmallChange = Me.ScaleHeight / 10

  HScroll1.Move 0, Me.ScaleHeight - HScroll1.Height, Me.ScaleWidth - VScroll1.Width, HScroll1.Height
  HScroll1.Max = Picture1.Width - Me.ScaleWidth
  If HScroll1.Max < 0 Then
    HScroll1.Max = 0
  End If
  HScroll1.LargeChange = Me.ScaleWidth
  HScroll1.SmallChange = Me.ScaleWidth / 10
End Sub

Add the following code to the vertical scrollbar change event:
Private Sub VScroll1_Change()

  Picture1.Top = VScroll1.Value * -1
End Sub

Add the following code to the horizontal scrollbar change event:
Private Sub HScroll1_Change()

  Picture1.Left = HScroll1.Value * -1
End Sub

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1462547
That having been said...
I would now suggest, if you have more controls than you have screen, you should use a tabbed screen instead.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

809 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