One time-saving feature of VBA (Visual BASIC for Applications) is its ability to create forms and dialog boxes to gather data for your programs. Using AutoCAD, we'll look at how to code VBA controls for user-defined forms or dialog boxes by focusing on a specific control in each of the next few installments. This is a fast-track approach. Many VBA reference books are available, so we'll skip the basic details and get right to implementing a VBA project with a user interface. Although this column is designed as a starting point for newcomers to VBA, you should at least be familiar with the VBA IDE (integrated development environment) components for placing controls on a form and changing their properties.
LET'S GET STARTED
To open AutoCAD's VBA IDE, select Tools | Macro | Visual Basic Editor. In the VB editor, select Insert | User Form to insert a blank form. Rename the form caption in the Properties window to Line1 Program.
This month we'll create a dialog box for input to create a line. We'll use the TextBox control to obtain the line's distance and angle. A TextBox control lets you edit or enter a single line of text. Figure 1 shows the size and placement of the controls.
|