Reusing Functions and Procedures

As you have seen in the examples in this chapter, you can create a procedure in either of two places: a form or a module. Where you place the procedure depends on where you need to use it and what its purpose is. If the procedure is specific to a form or modifies the properties of the form or its associated controls, you should probably place the procedure in the form itself.

If, on the other hand, you are using the procedure with multiple forms in your program or have a generic procedure used by multiple programs, you should place it in a module. The storage location of your procedure is determined by where you create it. If you want, you can move a procedure from a form to a module or vice versa using cut-and-paste ...

Get Special Edition Using Microsoft® Visual Basic® .NET 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.