Dim x1 As Long, y1 As Long, y0 As Long, x0 As Long, angle As Integer, newx1 As Long, newy1 As Long
Sub RotateLine(x1 As Long, y1 As Long, x0 As Long, y0 As Long, angle As Integer)
Dim LengthX As Long
Dim LengthY As Long
Dim LineLength As Double
'Get the difference between the X and Y points
LengthX = Abs(x1 - x0)
LengthY = Abs(y1 - y0)
'Get the length of the line
'Square Root of X squared + Y squared
LineLength = Sqr(LengthX ^ 2 + LengthY ^ 2)
'Cosine is the X coefficient of an angle
newx1 = x0 + (LineLength * Cos(angle))
'Sine is the Y coefficient of an angle
newy1 = y0 + (LineLength * Sin(angle))
y1 = newy1
x1 = newx1 'to use common variables.
End Sub
Sub Form_Load()
x0 = Form1.Width / 2
y0 = Form1.Height / 2
angle = 45
x1 = x0
y1 = Form1.Height / 6
RotateLine x1, y1, x0, y0, angle
Line (x0, y0)-(x1, y1)
End Sub
Sub HScroll1_Change()
angle = HScroll1.Value
RotateLine x1, y1, x0, y0, angle
Cls
Line (x0, y0)-(x1, y1)
End Sub