Chapter 5 Visual Basic Variables and Formulas, and the .NET Framework 135
- Click the Start Debugging button on the Standard toolbar.
- Click the Input Box button, type your name in the input box, and
then click OK.
Visual Basic stores the input in the program in the FullName variable and then displays
it in a message box. After typing the name Walter Harp in the input box, I received this
message box: - Click OK to close the message box. Then click Quit to close the program.
The program closes, and the development environment returns.
Working with Specific Data Types
The String data type is useful for managing text in your programs, but what about
numbers, dates, and other types of information? To allow for the efficient memory
management of all types of data, Visual Basic provides several additional data types
that you can use for your variables. Many of these are familiar data types from
earlier versions of BASIC or Visual Basic, and some of the data types were introduced
in Visual Studio 2005 to allow for the efficient processing of data in newer
64-bit computers.
Table 5-1 lists the fundamental (or elementary) data types in Visual Basic. Types preceded
by an S are designed for signed numbers, meaning that they can hold both positive and
negative values. Types preceded by a U are unsigned data types, meaning that they cannot
hold negative values. If your program needs to perform a lot of calculations, you might
gain a performance advantage in your programs if you choose the right data type for your
variables—a size that’s neither too big nor too small. In the next exercise, you’ll see how
several of these data types work.
Note Variable storage size is measured in bits. The amount of space required to store
one standard (ASCII) keyboard character in memory is 8 bits, which equals 1 byte.