Solved

Scrollbar

Posted on 1998-06-04
3
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

717 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