123
Chapter 5
Visual Basic Variables and Formulas,
and the .NET Framework
After completing this chapter, you will be able to:
n Use variables to store data in your programs.
n Get input by using the InputBox function.
n Display messages by using the MsgBox function.
n Work with different data types.
n Use variables and operators to manipulate data.
n Use methods in the .NET Framework.
n Use arithmetic operators and functions in formulas.
In this chapter, you’ll learn how to use variables and constants to store data temporarily in
your program, and how to use the InputBox and MsgBox functions to gather and present
information by using dialog boxes. You’ll also learn how to use functions and formulas
to perform calculations, and how to use arithmetic operators to perform tasks such as
multiplication and string concatenation. Finally, you’ll learn how to tap into the powerful
classes and methods of Microsoft .NET Framework 4 to perform mathematical calculations
and other useful work.
The Anatomy of a Visual Basic Program Statement
As you learned in Chapter 2, “Writing Your First Program,” a line of code in a Microsoft
Visual Basic program is called a program statement. A program statement is any
combination of Visual Basic keywords, properties, object names, variables, numbers, special
symbols, and other values that collectively create a valid instruction recognized by the
Visual Basic compiler. A complete program statement can be a simple keyword, such as
End
which halts the execution of a Visual Basic program, or it can be a combination of elements,
such as the following statement, which uses the TimeString property to assign the current
system time to the Text property of the Label1 object:
Label1.Text = TimeString