User Form Code and Event Procedures

A User Form can contain code as well as controls. In fact, the code is an essential part of a User Form's functionality. A User Form can contain just about any VBA code, including

  • module level declarations of variables, UDTs, and constants—note that UDTs in a User Form must be declared as Private;

  • property procedures;

  • methods—in other words, sub- and function procedures; and

  • event procedures.

In general, it is best to think of a User Form as a class module with a user interface. It can have methods and properties, just like a class module, but it also has controls and the events associated with the controls. You learned about module-level declarations in Chapter 12, about methods in Chapter 14, and about property ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.