Solved

SsVertical Sxroll bar for a form

Posted on 2004-08-05
8
286 Views
Last Modified: 2010-05-02
I would like to minimize the number of forms. Can I put a vertical scroll bar for the whole form. I tried to use the scroll bar, but I think I did not apply it correctly.

Gonzal13(Joe)
0
Comment
Question by:gonzal13
[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
  • 4
  • 4
8 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11730048
Have you tried using a Tab control instead?
These are very useful if you want to fit a lot on one form.
The best one to use is the SSTab control.
0
 
LVL 13

Author Comment

by:gonzal13
ID: 11730808
Here are some more Details: I have for example a list of lbl boxes with their associated txt boxs. I then through a msgbox have the commands tosave the data and then read the data. Latar the files will be open for access to calculations. I was hoping for something like MS Windows with its vertical scroll bars. Of the three books that I have none explain how to add data beyond the maximum size of the template. Templates take memory.

gonzal13(joe)
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11731581
Here's a first cut that works:

You need to place a vertical scrollbar on a form
Place a frame control on the form
Place a textbox INSIDE the frame so the frame contains the textbox
Set the index property of the textbox to 0 (zero)

Paste the following code into your form:

Option Explicit

Private bLoaded As Boolean
Private Sub Form_Load()
   
    With Form1
        .WindowState = vbMaximized
    End With
   
End Sub

Private Sub Form_Resize()

    With VScroll1
        .Max = 100
        .Min = 0
        .Top = 0
        .Left = Me.ScaleWidth - .Width
        .Height = Me.ScaleHeight
    End With
    With Frame1
        .BorderStyle = 0
        .Top = 0
        .Height = Me.ScaleHeight * 2
        .Width = VScroll1.Left
    End With
    If Not bLoaded Then
        Text1(0).Top = 20
        Dim i As Long
        For i = 1 To 100
            Load Text1(i)
            With Text1(i)
                .Visible = True
                .Text = "Text Box " & i
            End With
            With Text1(i - 1)
                Text1(i).Top = .Top + .Height + 50
                If .Top + .Height + 100 > Screen.Height * 2 Then
                    Exit For
                End If
            End With
        Next i
    End If
    bLoaded = True
End Sub

Private Sub VScroll1_Change()

    With Frame1
        .Top = -VScroll1.Value * .Height / (2 * VScroll1.Max)
    End With

End Sub
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 13

Author Comment

by:gonzal13
ID: 11737178
JR2003

Your reply is more than I expected. I did not realize that there would be any easy way to accomplish my goal.

I increased the points for the work that you did. I will test it out by cutting and pasting to avoid any typos.

Thanks again. Great work.
0
 
LVL 13

Author Comment

by:gonzal13
ID: 11737534
Jr2003:

I basically did a cut an past action.

I ran it and got an error message 'object required'

Private Sub Form_Load()
   
    With Form1
        .WindowState = vbMaximized  'OBJECT REQUIRED
    End With
   
End Sub


0
 
LVL 18

Expert Comment

by:JR2003
ID: 11738205
Your form must be called form1.
It's probably called something different so just change this line to:

    Me.WindowState = vbMaximized  'OBJECT REQUIRED
0
 
LVL 18

Accepted Solution

by:
JR2003 earned 100 total points
ID: 11738277
Sorry, my mistake the form load should just read:

Private Sub Form_Load()  

        Me.WindowState = vbMaximized
   
End Sub


All that function does is to maximize the form to illustrate how to scroll.

The the code works is all you controls are placed on a frame control so the frame contains the control. The frame controls is oversized to a size bigger than the actual screen size. This is your scrollable area. The scrollbar then just changes the value of the top of the frame.
0
 
LVL 13

Author Comment

by:gonzal13
ID: 11741095
Jr2003:

Well thank yiou very much. You are very explicit in your programming and do not assume that the questioner actually knows allot about VB6.

gonzal13(joe)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

738 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