X1, Y1, X2, Y2 Properties

See Also5N1WO8                 Example1PGKZBE>Low

Apply To



Determine the coordinates of the starting point (X1, Y1) and ending point (X2, Y2) of a line control.  The horizontal coordinates are X1 and X2; the vertical coordinates are Y1 and Y2.


[form.]line.X1[ = numericexpression ]

[form.]line.Y1[ = numericexpression ]

[form.]line.X2[ = numericexpression ]

[form.]line.Y2[ = numericexpression ]


Use these properties to dynamically extend a line from one point to another at run time.  For example, you can show the relationships of items in one list to items in another list, or connect points on a map.

Data Type


See Also


Left, Top Properties1CIZPD6

Line MethodGU01B0


Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"

X1, Y1, X2, Y2 Properties Example

The example is an animated line that walks down the form when you click the form.  To try this example, paste the code into the Declarations section of a form that contains a timer and a line control.  Then press F5 and click the form.

Sub Form_Load ()
  Timer1.Interval = 100              ' Set Timer interval.
  ' Position the line near the upper left corner.
  Line1.X1 = 100
  Line1.Y1 = 100
  Line1.X2 = 500
  Line1.Y2 = 300
End Sub

Sub Form_Click ()
  Timer1.Enabled = True              ' Start the timer.
End Sub

Sub Timer1_Timer ()
  Static Odd                         ' Declare variable.
  If Odd Then
    Line1.X2 = Line1.X2 + 250
    Line1.Y2 = Line1.Y2 + 600
    Line1.X1 = Line1.X1 + 250
    Line1.Y1 = Line1.Y1 + 600
  End If
  Odd = Not Odd                      ' Toggle the value.
  ' If the line is off the form, start over.
  If Line1.Y1 > ScaleHeight Then
    Timer1.Enabled = False           ' Wait for new click.
    Line1.X1 = 100
    Line1.Y1 = 100
    Line1.X2 = 500
    Line1.Y2 = 300
    Odd = False
  End If
End Sub