Types of Procedures

VBA provides you with five different types of procedures.

  • A sub procedure is an independent, named section of code that performs some action.

  • A function procedure is identical to a sub procedure except it also returns data to the calling program (which a sub procedure does not do).

  • A method is a sub- or function procedure that is located in a class module.

  • A property procedure is used to access properties in user-defined classes. These are covered in Chapter 18.

  • An event procedure is executed automatically when the corresponding event, such as a mouse click, occurs.

Event procedures are a special case. You, the programmer, do not create event procedures but only add the code to them that you want executed when the event occurs. ...

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.