MANAGING CODE

Subroutines and functions enable you to break an otherwise unwieldy chunk of code into manageable pieces. They allow you to extract code that you may need to use under more than one circumstance and place it in one location where you can call it as needed. This not only reduces repetition within your code but also enables you to maintain and update the code in a single location.

A subroutine performs a task for the code that invokes it. A function performs a task and then returns some value. The value may be the result of a calculation or a status code indicating whether the function succeeded or failed.

Together, subroutines and functions are sometimes called routines or procedures. They are also sometimes called methods, particularly when they are subroutines or functions belonging to a class. Subroutines are also occasionally called sub procedures or less formally Subs.

This chapter describes subroutines and functions. It explains the syntax for declaring and using each in a Visual Basic application. It also provides some tips for making routines more maintainable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.104.243