Instead of use the line method use a Line object (added from the ToolBox). Make the Line object into a control array, done by setting its Index property to 0. Now when you load your project do the following:
Now call the DrawArrow procedure in the function where you randomally generate the main line as follows:Code:Private Sub Form_Load() Load Line1(1) Load Line1(2) Load Line1(3) End Sub
The parameters for DrawArrow are as follows:Code:Call DrawArrow(Line1(0), Line1(1), Line1(2), Line1(3), 200, 100) Line1(0).Visible = True Line1(1).Visible = True Line1(2).Visible = True Line1(3).Visible = True
Shaft As Line
- The main line that you're drawing.
Because the arrow head is a triangle you need three lines to create it.
TipLeft As Line
- The left side of the Isoceles triangle for the arrow head.
TipRight As Line
- The right side of the Isoceles triangle for the arrow head.
TipBase As Line
- The base (the perpendicular line to the main line) of the arrow head triangle.
TipLength As Single
- How far down the main line from the tip of the main line that you want the arrow head's base to be.
TipWidth As Single
- How wide to make the base of the arrow head (ie. the perpendicular line to the main line).
To elaborate further, three of the four lines you pass in
are used for the arrow head and are positioned by the procedure, you specify the dimensions of the triangle through the TipLength and TipWidth parameters.
And just to make it really easy, here's the modified procedure to draw the arrow head at the other end of the line:
There you go, hope it's meets your needs now, let me know either way.Code:Private Sub DrawArrow(Shaft As Line, TipLeft As Line, TipRight As Line, TipBase As Line, TipLength As Single, TipWidth As Single) Dim sngTipLengthAsFraction As Single Dim sngTipWidthAsFraction As Single Dim sngShaftLength As Single sngShaftLength = Sqr((Shaft.X1 - Shaft.X2) ^ 2 + (Shaft.Y1 - Shaft.Y2) ^ 2) sngTipLengthAsFraction = TipLength / sngShaftLength sngTipWidthAsFraction = TipWidth / sngShaftLength TipBase.X1 = Shaft.X2 - sngTipLengthAsFraction * (Shaft.X2 - Shaft.X1) + sngTipWidthAsFraction * (Shaft.Y1 - Shaft.Y2) TipBase.Y1 = Shaft.Y2 - sngTipLengthAsFraction * (Shaft.Y2 - Shaft.Y1) + sngTipWidthAsFraction * (Shaft.X2 - Shaft.X1) TipBase.X2 = Shaft.X2 - sngTipLengthAsFraction * (Shaft.X2 - Shaft.X1) - sngTipWidthAsFraction * (Shaft.Y1 - Shaft.Y2) TipBase.Y2 = Shaft.Y2 - sngTipLengthAsFraction * (Shaft.Y2 - Shaft.Y1) - sngTipWidthAsFraction * (Shaft.X2 - Shaft.X1) TipRight.X1 = Shaft.X2 TipRight.Y1 = Shaft.Y2 TipRight.X2 = TipBase.X2 TipRight.Y2 = TipBase.Y2 TipLeft.X1 = Shaft.X2 TipLeft.Y1 = Shaft.Y2 TipLeft.X2 = TipBase.X1 TipLeft.Y2 = TipBase.Y1 End Sub
Later.




Reply With Quote