Data Types

Visual Basic .NET has a number of predefined data types. You also can create your own data types using structures and classes. However, even those custom data types build on the predefined ones covered in this module.

Visual Basic .NET has three categories of predefined data types:

■ Numeric Numbers, whether whole numbers such as 5 or -5, or fractional ones such as -.5, .5, or 5.5

■ Character A single character, such as A or 1, or a number of characters, such as those contained in this sentence

■ Miscellaneous The remaining data types, Boolean, Date, and Object

Table 4-1 lists and describes the predefined data types.

Table 4-1: Predefined Visual Basic .NET Data Types.

Type

Bytes

Range

Boolean

2

True or False

Byte

1

0 to 255

Char

2

0 to 65535

Date

8 1

January 1, 0001 to December 31, 9999

Decimal

12

+/-79,228,162,514,264,337,593,543,950,335 with no decimal point +/-7.9228162514264337593543950335 with 28 places to the right of the decimal smallest non-zero number is +/-0.0000000000000000000000000001

Double (double -precision floatingpoint)

8

-1.79769313486231E308 to -4.94065645841247E -324 for negative values, 4.94065645841247E-324 to 1.79769313486232E308 for positive values

Integer

4

-2,147,483,648 to 2,147,483,647

Long (long integer)

8

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Object

4

Any type can be stored in a variable of type Object

Short

2

-32,768 to 32,767

Single

4

-3.402823E38 to -1.401298E-45 for negative values,

1.401298E-45 to 3.402823E38 for positive values

String

10 bytes + 2 bytes for every character in the string

0 to approximately 2 billion (2 A 31) characters

Your first task is to memorize everything in this table. Just kidding. As has been stressed in previous modules, memorization is not important; understanding the concepts is. Unless I was looking at this book at the time, I would not know that the highest value of the Long data type is 9,223,372,036,854,775,807. Nor would I need to know that specific piece of information, as I could easily look it up. Rather, it is important to understand the concepts such as variable size and range, to which we now turn.

Was this article helpful?

0 0

Post a comment