Left, Top Properties (ActiveX Controls)
Left — returns or sets the distance between the internal left edge of an object and the left edge of its container.
Top — returns or sets the distance between the internal top edge of an object and the top edge of its container.
object.Left [= value]
object.Top [= value]
The Left and Top property syntaxes have these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|value||A numeric expression specifying distance.|
For a form, the Left and Top properties are always expressed in twips; for a control, they are measured in units depending on the coordinate system of its container. The values for these properties change as the object is moved by the user or by code.
For either property, you can specify a single-precision number.
Use the Left, Top, Height, and Width properties for operations based on an object's external dimensions, such as moving or resizing. Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations based on an object's internal dimensions, such as drawing or moving objects that are contained within the object.
This example sets the size of a form to 75 percent 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, and then press F5 and click the form.
Private Sub Form_Click () 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