Left, Top Properties

See Also80EC0JD                 Example1X04Z34>Low

Apply To

Form14TJ2LN, MDI form1ILMZQ7, check box9P3BU5, combo box1YZXFF6, command buttonXJSPC0, common dialog,1H1HYJI 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, shape9JZFLA, text boxYPYZDG, timer3MVR08J, vertical scroll bar1JSJOS7.

Description

         Leftdetermines the distance between the internal left edge of an object and the left edge of its container0LIF9VL.

         Topdetermines the distance between the internal top edge of an object and the top edge of its container.

 

For a form, the Left and Top properties are always expressed in twips2SWJ8D3; for a control, they are measured in units according to the coordinate system of its container.  The values for these properties change as the object is moved by the user or by code.  For a timer, these properties are not available at run time.

Usage

[form.][control.]Left[ = x ]

[form.][control.]Top[ = y ]

Remarks

For both properties, you can specify a single-precision number.

Use Left and Top, and the Height and WidthL14VJZ properties, for operations based on an object's external dimensions, such as moving or resizing.  Use the ScaleLeft138Z3ME, ScaleTop138Z3ME, ScaleHeight3J8U7ZN, and ScaleWidth3J8U7ZN properties for operations based on an object's internal dimensions, such as drawing or moving objects that are contained within the object.  The scale-related properties apply only to forms, picture boxes, and the Printer objectKP972I.

Data Type

Single6H5W9RZ


See Also

Help:

Left FunctionGU9X0I

Move Method103G76J

ScaleHeight, ScaleWidth Properties3J8U7ZN

ScaleLeft, ScaleTop Properties138Z3ME

ScaleMode Property5SNY0BP

 

Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"


Left, Top 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_Click ()
  Width = Screen.Width * .75             ' Set height of form.
  Height = Screen.Height * .75           ' Set width of form.
  Left = (Screen.Width - Width) / 2      ' Center form horizontally.
  Top = (Screen.Height - Height) / 2     ' Center form vertically.
End Sub