- Sub Procedures
- Creating Functions
- Using Optional Arguments
- Passing a Variable Number of Arguments
- Preserving Data Between Procedure Calls
- Understanding Scope
- Handling Runtime Errors
- Unstructured Exception Handling
- Structured Exception Handling
- Introducing Classes and Objects
- Summary
- Q&A
- Workshop
Summary
Today, we saw a great deal about the Visual Basic language. We started by looking at how to create procedures in Visual Basic .NET.
There are two types of procedures: Sub procedures and functions. They can both contain sets of Visual Basic statements that may be called, but only functions can return values. We saw that we can pass arguments to procedures, including optional arguments. We also saw how to support variable-length argument lists. And we also saw how to preserve data values between calls to proceduresboth with static variables and module-level variables.
That introduced us to the idea of scope. An element's scope is the area in a program where that element is accessible. We saw that there are four levels of scope: block level, procedure level, module level, and namespace level.
We also looked at runtime error handling today. Runtime errors are called exceptions, and the two types of exception handling in Visual Basic are structured and unstructured exception handling. Structured exception handling centers around the Try/Catch statement, and unstructured exception handling uses the On Error statement. We saw how to catch exceptions, throw our own exceptions, filter exceptions, and more.
We also got an introduction to classes and objects in OOP today. We saw how to create a class, create an object of that class, and create public data members, properties, and methods in a class. That information will come in handy throughout the book.
And that's it! We now have the foundation in the Visual Basic language we'll need for the coming days. Tomorrow, we're going to begin putting to work what we've seen so far as we start working with Windows applications.