Link to home
Start Free TrialLog in
Avatar of et1dkn
et1dkn

asked on

Draw a Circle with Spokes

Win95/VB5 Pro:
I want to draw a Circle with radius of any length. Then use Line function to draw spokes(radius) at every 10 or 20 degrees (programmable).  I understand that this is math oriented but wonder if anyone can help.
ASKER CERTIFIED SOLUTION
Avatar of caraf_g
caraf_g

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of caraf_g
caraf_g

I hope this works for you - I have VB5 Enterprise edition. If not, it just contains a simple form with
1 button
1 text box
1 label saying "Spokes"

The idea is that you enter the number of spokes in the text box and then hit the button which will draw the requested circle with spokes. Leave the top left of the form blank so there is space for the circle to be displayed.

The code in the form module follows in the next comment.
Option Explicit

Private Sub Command1_Click()

Me.Cls

Dim Pi As Double
Dim intSpokes As Integer
Dim intCount As Integer

intSpokes = Val(Text1.Text)

Pi = 3.141592653

Me.Circle (1000, 1000), 1000

Dim dblX As Double
Dim dblY As Double

For intCount = 0 To intSpokes - 1
    dblX = 1000 * Cos(intCount * ((2 * Pi) / intSpokes))
    dblY = 1000 * Sin(intCount * ((2 * Pi) / intSpokes))
    Me.Line (1000, 1000)-(1000 + dblX, 1000 + dblY)
Next

End Sub

(You only need to worry about those last two comments if you can't download the .zip file from the site, or if it won't work in VB5 prof..)
Avatar of et1dkn

ASKER

C:

Thanks much for your quick answer...been a LONG time since my last Geometry class..Thanks for breaking the log jam.

Respects

Dan

The zip file has been removed from my homepage