Solved

Scrollbar

Posted on 1998-06-04
3
250 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 50 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now