Private Sub DrawXY()
'reset fields if you are storing values in them
Me.xyvalues.Value = ""
Me.xvalues.Value = ""
Me.yvalues.Value = ""
radius = 130 'where you want to drill holes out to
x = 0
y = 0
xoffset = 2.5 'increment x by this for each string of holes
yoffset = 4 'each hole in the string spaced this far apart
yodd = 2 'additional offset for the first hole in each alternate string
stringcounter = 0
Do While stringcounter * xoffset < radius 'repeat until the radius is reached
x = stringcounter * xoffset 'position of string
y = 0
firsthole = 1 'this is the first hole of the string, apply additional offset on alternate rows
'generate ys for x
Do While Sqr((x * x) + (y * y)) < radius 'set up new holes on y axis until radius of circle reached
'increase y offset for alternate lines
If stringcounter = 0 Then 'apply the additional offset to alternate rows
ystart = 0
ElseIf IIf(stringcounter Mod 2, "odd", "even") = "odd" Then
ystart = yodd
Else: ystart = 0
End If
'set y value appropriately
If firsthole = 1 Then
y = y + ystart
firsthole = 0
Else: y = y + yoffset
End If
'Do whatever you want with x and y values here, I put them in a field in access
Me.xyvalues.Value = Me.xyvalues.Value & "(" & x & "," & y & ")" & vbNewLine
Me.xvalues.Value = Me.xvalues.Value & x & vbNewLine
Me.yvalues.Value = Me.yvalues.Value & y & vbNewLine
Loop
'increment x
stringcounter = stringcounter + 1 'start the next string of holes
Loop
End Sub
So that was nice.if in the future , you need me do something for you , pls feel freely contact with me .
I will try my best to help you .
Thanks in advance
Have a nice day and happy forever.
Enter your email address to join: