Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const Pi = 3.14159265358979 'atn(1)*4
Private Sub Form_Load()
Me.AutoRedraw = True
Me.WindowState = 2
Me.BackColor = vbWhite
Me.Print "Double Click The form"
End Sub
Private Sub Form_DblClick()
Me.DrawWidth = 5
'Just Draw a Box
Me.Line (Me.ScaleWidth / 2 - 1000, Me.ScaleHeight / 2 - 1000)-(Me.ScaleWidth / 2 + 1000, Me.ScaleHeight / 2 + 1000), vbBlack, B
PlotArc Me.ScaleWidth / 2, Me.ScaleHeight / 2, 1000, vbRed, 270, 30
End Sub
'==============================================================
'PlotArc
'--------
'X - X coordinate of the center
'Y - Y Coordinate of the center
'R - Radius of the arc
'Color - Optional as a long value {default: black}
'Theta - Optional angle of sweep as integer {default:360}
'Delay - In milliseconds between each pixel. {default:No delay}
'==============================================================
Private Sub PlotArc(ByVal X As Single, ByVal Y As Single, ByVal R As Long, Optional Color As Long = vbBlack, Optional Theta As Integer = 360, Optional Delay As Long)
Dim i As Integer
For i = 0 To Theta
Me.PSet (X + (R * Cos(i * Pi / 180)), Y + (R * Sin(i * Pi / 180))), Color
'---- Note:
'You can change where the drawing starts, the default starts East..
'So.. for example to start from South...add 90 to i..
'Me.PSet (X + (R * Cos((i + 90) * Pi / 180)), Y + (R * Sin((i + 90) * Pi / 180))), Color
'You can change the direction of rotation.. Just Swap Sin and cos
'Me.PSet (X + (R * Sin((i + 90) * Pi / 180)), Y + (R * Cos((i + 90) * Pi / 180))), Color
If Not (IsMissing(Delay) Or Delay = 0) Then
Sleep Delay
Me.Refresh
End If
Next
End Sub