Solved

Scrollbar

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now