Posted on 2006-05-08
Last Modified: 2010-05-18
Hi guys!

I have a form with a width of 15420. This form contains a Picturebox, which width is 865, but the problem is both window and Picturebox have almost the same width. Somehow they have a different scale.

I tried modifying the Scalemode property, but nothing changes.

What I need is the Picturebox to addapt its size every time the form is resized, but with these different scales I don't know how to do that.

Any ideas?

Question by:pvg1975

    Author Comment

    Other controls as Shape, Texbox, etc have the right scale (as the form width): 14564, 8334, 2245, etc but the Pictureboxes!
    LVL 13

    Accepted Solution


    Check that all your controls have the scalemode

    Your picturebox may be inside another picturebox or inside a frame with a different scalemode than the one in the form
    LVL 13

    Expert Comment

    Your form uses a unit called twip, where the picturebox is using the pixel unit. Usually 15 twip = 1 pixel.
    There are several ways to solve this problem

    - You can set the picturebox scalemode = twip so the unit used by the picturebox is the same as the one used by the form.
    This sollution is simple in theory but if you have coded other functions that considers the picturebox unit is pixel you'll have to modify these functions. This mission may get you into a lot of mess, so if that is your situation consider the next sollution.

    - You can set the form scalemode = pixel
    to read the width property of the form:
        Dim PixWidth as integer
        PixWidth = Me.ScaleWidth

    to set the form's width:
        Me.Width = 100 * Screen.TwipsPerPixelX ' this is equevelant to 100 pixels

    NOTE: Parent scalemode property overrides child scalemode property

    Author Comment

    Thanks guys!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Introduction While answering a recent question ( 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…
    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…
    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…

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now