lubracali Posted January 22, 2011 Share Posted January 22, 2011 I was wondering if there is a way to make an array variable with an integer in is name. When I indicate a point in autocad/vba I have to use an array. Dim pt1(0 To 2) As Double pt1(0) = x pt1(1) = y pt1(2) = z If I want to write a loop for...next, according to a set of values contained in some textboxes and put into another array, I can not change to the index of the point (pt1, 1 is the index). Let me explain. If I want to draw circles whose centers x coordinate are placed in 3 textboxes, I can draw them one at a time or can I try to write a for loop next. Dim txt(1 To 3) As Double txt(1) = TextBox1.Text txt(2) = textbox2.Text txt(3) = textbox3.Text Dim pt1(0 To 2) As Double Dim pt2(0 To 2) As Double Dim pt3(0 To 2) As Double Dim K As Integer Dim circ(1 To 3) As AcadCircle For K = 1 To 3 ptK(0) = txt(K) ptK(1) = 100 Set circ(K) = ThisDrawing.ModelSpace.AddCircle(ptK, 6) Next K The problem is that VBA does not recognize ptK as a depending of the index K. Quote Link to comment Share on other sites More sharing options...
SEANT Posted January 22, 2011 Share Posted January 22, 2011 Variable names can not be processed in that way. I may not grasp the full scope of the problem but it seems like this produces the desired result. Dim Pt(2) as Double Dim circ(2) As AcadCircle Dim i as Integer For i = 0 to 2 Pt(0) = txt(i + 1) Pt(1) = 100 Pt(2) = 0 Set circ(i) = ThisDrawing.ModelSpace.AddCircle(Pt, 6) Next Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.