P. 1
81959924 AutoCAD VBA Programming Tools and Techniques

81959924 AutoCAD VBA Programming Tools and Techniques

|Views: 280|Likes:
Published by xuanhuynh

More info:

Published by: xuanhuynh on Nov 02, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/12/2013

pdf

text

original

Page 100

The VBA LBound and UBound functions provide the required information as to how many values can be found in the
array. These values are used to define the limits to be used in a For-Next loop that will go through each value in the list.

Note how the point values themselves are accessed from the array. The X value is found at position (I) while the Y
value is found at (I+1) and Z at (I+2). In order to advance a whole point at a time in the For-Next loop, the loop counter
variable (I) is incremented by two during each pass of the loop. It will automatically be incremented by a value of 1
because of the For-Next loop.

Dim I as Integer
For I = LBound(Pnts) to UBound(Pnts)
S$ = Pnts(I) & ", " & Pnts(I+1) & ", " & Pnts(I+2)
MsgBox "Found intersection at " & S$
I = I + 2
Next I

If the resulting Pnts array was empty, the following code is executed. The user is told via a message box that there are
no intersections between the two objects. The second End If statement closes the earlier test to see if the second object
was selected properly.

Else

MsgBox "No intersections found"

End If
End If

It does not take long to get used to working in the VBA environment. In fact, with the programming tools native in the
VBA IDE, you will spend less time learning the objects than might be expected. This has to do with the automatic
typing feature that accompanies all objects known to the system. With the easy access of the online help facility, you
can quickly find the object details in question. Perhaps the only difficulty with the online help system is that the VBA
files have some information,

< previous page

page_100

next page >

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->