Display and Hide Forms
 
 
 

Now you have a beautifully designed form with fully functional code behind all the controls. The last step is getting the form displayed to the user at run-time. Displaying the form is accomplished through the VBA Show method. The Show method can be called from any code module in your application.

The form you created is modal by default, so the user will not be able to interact with AutoCAD directly while the form is displayed. For example, the user cannot select a point or object in the drawing with the form displayed. To allow the user access to the AutoCAD drawing, use the VBA Hide method. The Hide method hides the form and allows the user limited access to AutoCAD. When using the Hide method it is important to remember that the form is not unloaded from memory. It will retain all current values while hidden.

The Hide method is called in the same manner as the Show method.

Display a form

This example will display the form named “UserForm1”:

Public Sub MyApplication()
   UserForm1.Show
End Sub

The subroutine (and consequently the display of your form) is now callable as a macro from the VBARUN command or from an AutoCAD menu.

Hide a form

This example hides the form named “UserForm1”:

Public Sub MyAppHide()
   UserForm1.Hide
End Sub