Resizing All Controls in VB6

Posted on 2007-10-09
Last Modified: 2013-12-26
I need a loop for resizing everything on the form. Someone else had a similar idea
The answer wasn't what I was looking for, I figure it may be better to start from scratch...
This is the best solution I could find:
This sort of loop was close to what I was looking for, but ...blah blah blah, I need something else

I have maxed out the control limit on this form/project, which is why I need a loop.

The reason for the resize in that I made a program in 1280 x 1024, and as I said before There's so many controls that it's one away from maxing out the limit on the cotrols. Program is complete, except for this.

Please put some thought in this, I have...for months, last hope
Question by:PME_Inc
    LVL 23

    Accepted Solution

    If I understand you right, you just want to resize all your controls so they will all fit on your form??
    This will increase or decrease all your forms controls, and reposition them to match:

    Put this sub in your form:

    Private Sub AdjustControls(ByVal value As Single)
        On Error Resume Next
        Dim c As Control
        Dim aa As Integer
        Dim temp
        For Each c In Me.Controls
                c.Left = c.Left * value
                c.Top = c.Top * value
                c.Width = c.Width * value
                c.Height = c.Height * value
    End Sub

    Then call it like this:
          AdjustControls 0.5
    That will half the size of each control

    If you change the 0.5 to a 2, then all the controls sizes will double, so as you can see, you can put any number in there you want.  So if you put say...0.9, then they would decrease in size slightly, or 1.1 and they would increase slightly.

    All the controls will reposition themselves to where they need to be also...


    LVL 23

    Assisted Solution

    Oh...Remove these 2 lines:
        Dim aa As Integer
        Dim temp
    You don't need those.  I just cut this code snippit out of another app I wrote awhile back and forgot to take those 2 lines out...

    LVL 23

    Expert Comment

    Thanks for the points and the grade!...I hope that simple bit of code did a good job for you...


    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

    This is an explanation of a simple data model to help parse a JSON feed
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    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…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    734 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

    19 Experts available now in Live!

    Get 1:1 Help Now