How can I make a line spin around its own center???
Printable View
How can I make a line spin around its own center???
Put this on the form with a line, and run!Code:Private Sub Form_Activate()
Dim centerx&, centery&, radius&, angle!
centerx = (Line1.X1 + Line1.X2) / 2
centery = (Line1.Y1 + Line1.Y2) / 2
radius = Sqr((Line1.Y1 - Line1.Y2) ^ 2 + (Line1.X1 - Line1.X2) ^ 2) / 2
Do
angle = angle + 0.01
Line1.X1 = centerx + Cos(angle) * radius
Line1.X2 = centerx + Cos(angle + 3.1415) * radius
Line1.Y1 = centery + Sin(angle) * radius
Line1.Y2 = centery + Sin(angle + 3.1415) * radius
DoEvents
If angle > 6.283 Then angle = angle - 6.283
caption = angle
Loop While Forms.Count
End Sub
Thanks you very much! Thats just what I was looking for!! :)