ASP.NET 2.0 All-In-One Desk Reference For Dummies®
by Doug Lowe, Jeff Cogswell, Ken Cox - Microsoft MVP
Chapter 3. Working With Procedures, Exceptions, and Arrays
In This Chapter
✓ | Working with Sub procedures |
✓ | Using Function procedures to best effect |
✓ | Examining the nuances of parameters |
✓ | Dealing with exceptions |
✓ | Getting arrays to work right |
This chapter introduces you to three individually important but unrelated aspects of Visual Basic.Net (VB.NET) programming: procedures and functions, exceptions, and arrays.
A procedure is a group of sequential statements that have a name in common — and can be executed by calling the group (by name, of course) from some other place in the program. VB.NET lets you use two distinct types of procedures: Sub procedures and Function procedures. The difference between the two is that a Function procedure returns a calculated value, while a Sub procedure doesn’t return a value.
Sub procedures are used extensively in ASP.NET to handle events such as the Load event for a page or the Click event for a button. In addition, you can create your own Sub or Function procedures. This often helps you simplify your code by enabling you to break a long Sub procedure into several shorter Sub or Function procedures.
Note that Sub procedures are often called subroutines, and both Sub and Function procedures are often called methods. The only difference between a Sub procedure and a Function procedure is that a Function procedure returns a value, while a Sub procedure does not.
Another highly useful (okay, indispensable) aspect of VB.NET programming is handling exceptions. This ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access