User Form

Although not contained in separate files as in a stand-alone Visual Basic application, the UserForm module is an integral part of your project. The UserForm module contains the procedures you write to react to the UserForm's events and the controls you place on your UserForm. The UserForm module contains UserForm-level procedures, variables, and constants specific to the project. Also, if you were to export the UserForm module to a file and look at it with a text editor, you would see descriptions of the UserForm and all the controls and their property settings.

To import a UserForm module file (.frm), choose File > Import File or press Ctrl+M. The UserForm module file must have been created by AutoCAD or a similar VBA-enabled application, such as Microsoft Word. If you create the UserForm module file in Visual Basic using the Microsoft Forms 2.0 form add-in, you can import them too. You can't, however, import a .frm file created by Visual Basic.

■ Note UserForm modules in earlier versions of VBA are modal, meaning that you can't click away from them to other applications that might be running. To let the user access the AutoCAD window, you must first hide your application window. In AutoCAD 2006 with VBA 6.3, set the form window's ShowModal property at design time to make UserForm modules modal (True) or modeless (False).


The Standard module file (.bas) generally contains procedures and declarations that other modules in your application can access. The Standard module can contain global (available to the entire application) or module-level declarations of procedures, variables, constants, and programmer-defined data types. Your application does not have to use the code that you write in a Standard module. The Standard module gives you a place to put code that may be used frequently and that you would like to have handy when the need arises. Code modules may also include subroutines or functions that you will use frequently throughout your programs.


The foundation of object-oriented programming in Visual Basic is the Class module. You can create new objects by writing code in Class modules that implement their own properties, methods, and events. They support the same features as the UserForm module but allow a new level of functionality such as creating ActiveX controls, ActiveX documents, and so on. AutoCAD VBA can create only code components. To create components such as ActiveX controls and ActiveX documents, you need Visual Basic.

Class modules hold the key to creating new objects. These objects may contain their own properties and methods and may be instantiated more than once. Class modules let you combine functionality into a single source. Tasks such as API function calls and common database activities are prime candidates for Class modules.

0 0

Post a comment