Height, Width Properties

See Also2KLHAKS                 Example1SOSQVY>Low

Apply To

Form14TJ2LN, MDI form1ILMZQ7, check box9P3BU5, combo box1YZXFF6, command buttonXJSPC0, data control2E1FEX3, directory list boxO9U5A0, drive list box5WJO0PW, file list box1M6S8UX, frame1KX6ZP8, grid2VGT0PT, horizontal scroll bar1JSJOS7, image9A4FCA, label3MNIZ8D, list boxG11UCK, OLE control2HQDVVU, option buttonJYBO08, picture box31MYIWX, Printer objectCBQUDQ, Screen object1052P0, shape9JZFLA, text boxYPYZDG, vertical scroll bar1JSJOS7.


Determine the dimensions of an object.


{ [form.][control.]|Printer.|Screen.}Height[ = numericexpression ]

{ [form.][control.]|Printer.|Screen.}Width[ = numericexpression ]


Measurements are calculated as follows:

         Formthe external height and width of the form, including the borders and title bar32N908X.

         Controlmeasured from the center of the control's border so that controls with different border widths align correctly.  These properties use the scale units of a control's container0LIF9VL.

         Printer objectthe physical dimensions of the paper set up for the printing device; not available at design time and read-only at run time.

         Screen objectthe height and width of the screen; not available at design time and read-only at run time.


For a form, Printer object, and Screen object, these properties are always measured in twips2SWJ8D3.  For a form or control, the values for these properties change as the object is sized by the user or by code.  Maximum limits of these properties for all objects are system-dependent.

Use the Height, Width, Left, and Top1CIZPD6 properties for operations or calculations based on an object's total area, such as sizing or moving the object.  Use the ScaleLeft, ScaleTop138Z3ME, ScaleHeight, and ScaleWidth3J8U7ZN properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.


Note   The Height property can't be changed for drive list boxes or for combo boxes whose Style property is 0 (Dropdown Combo) or 2 (Dropdown List).


Data Type


See Also


Left, Top Properties1CIZPD6

Move Method103G76J

ScaleHeight, ScaleWidth Properties3J8U7ZN

ScaleLeft, ScaleTop Properties138Z3ME

Width # StatementQ6GH4W

Height, Width Properties Example

The example sets the size of a form to 75% of screen size, and centers the form when it is loaded.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

Sub Form_Load ()
  Width = Screen.Width * .75             ' Set width of form.
  Height = Screen.Height * .75           ' Set height of form.
  Left = (Screen.Width - Width) / 2      ' Center form horizontally.
  Top = (Screen.Height - Height) / 2     ' Center form vertically.
End Sub