Understanding Data Types

Okay, you know what a variable does and how to name it. But what can you store in a variable? The simple answer is: almost anything. A variable can hold a numeric value; a string of text; or a reference to an object, such as a form, control, or database. This chapter looks specifically at using variables to store numbers, strings, and dates. Table 6.2 lists Visual Basic’s data types:

Table 6.2. Visual Basic Data Types
Visual Basic .NET Data Type Values Stored Example Memory Requirements
Boolean True/False True 2 bytes
Byte 0–255 122 1 byte
Char Single Character A 2 bytes
Date Dates and Times 12/21/1970 02:00 PM 8 bytes
Decimal Decimal or Whole 19.95D 16 bytes
Double Decimal Numbers 1.23E-10 8 bytes
Integer Whole Numbers ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.