See Also Example
Apply To
Form, MDI form
Description
Determine the dimensions of an object.
Usage
{ [form.][control.]|Printer.|Screen.}Height[ = numericexpression ]
{ [form.][control.]|Printer.|Screen.}Width[ = numericexpression ]
Remarks
Measurements are calculated as follows:
Formthe external height and width of the form, including the borders and title bar .
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 container .
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 twips 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 Top Use the ScaleLeft, ScaleTop , ScaleHeight, and ScaleWidth 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
Single
Help:
Left, Top Properties
Move Method
ScaleHeight, ScaleWidth Properties
ScaleLeft, ScaleTop Properties
Width # Statement
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