Basic Programming in Visual Basic .NET

Basic Programming in Visual Basic .NETThis chapter looks at variable declaration and initialization, block scope, static variables, and more on arrays and abstract data types. I will also introduce you to the concept of shadow variables, and provide you with some more examples on defining procedures and structures. Near the end of this chapter, we will look at the new garbage collector and the impact it has on using objects. Finally, this chapter wraps up with comprehensive coverage of exception handling. Because you will use exception handling in all of the code you write-though perhaps not all procedures-you need to master the concepts of exception handling early.

Declaring and Initializing Variables
There is one significant difference in the way you write declarations for simple types and object types. That difference is the use of the keyword New. (We’ll look at New more in the section “Using Objects.”)
Variables can be declared and initialized in Visual Basic .NET on a single line. In addition to resulting in fewer lines of code, this new feature can be applied with some simple rules to make code more robust.

Initialize Variables
In programming, so many things can go wrong that we need to hedge as often as possible to make things go right. These hedges, like splitting aces in blackjack, are good practices that help us progress deliberately without sweating details. By providing an initial value for variables, we are providing a reference point, or known state, that we can use to evaluate a variable. Essentially, by providing an initial state and controlling the value of variables, we can always evaluate a variable to determine whether its value is within an acceptable range. However, if we never expressed what an acceptable initial value was, we can’t test the initial state.

Website: www.ftponline.com | Filesize: 82kb
No of Page(s): 28
Click here to download Basic Programming in Visual Basic .NET.

Related Tutorial

Tags: , , , , , ,

Comments

Leave a Reply