Chapter 5. VB.NET Language Fundamentals
Chapter 2 demonstrates a very simple VB.NET program that prints the text string “Hello world!” to the console screen and provides a line-by-line analysis of that program. However, even that very simple program was complex enough that some of the details had to be skipped over. The current chapter begins an in-depth exploration of the syntax and structure of the VB.NET language.
Types
Every object you create or use in a VB.NET program must have a specific type (e.g., you must declare the object to be an integer or a string or a Dog or a Button). The type tells the compiler how big the object is and what it can do.
Types come in two flavors: those that are built into the language (intrinsic types) and types you create (classes, structs, and interfaces, discussed in Chapter 8, Chapter 12, and Chapter 13, respectively). VB.NET offers a number of intrinsic types, shown in Table 5-1.
|
Type |
Size (in bytes) |
.NET type |
Description |
|
Boolean |
1 |
Boolean |
True or false. |
|
Byte |
1 |
Byte |
Unsigned (values 0-255). |
|
Char |
2 |
Char |
Unicode characters. |
|
Date |
8 |
DateTime |
Midnight 1/1/0001 through 11:59:59 12/31/9999. |
|
Decimal |
12 |
Decimal |
Fixed-precision numbers up to 28 digits and the position of the decimal point; typically used in financial calculations; requires the suffix “m” or “M.” |
|
Double |
8 |
Double |
Double-precision floating-point numbers; holds the values from approximately +/-5.0 * 10-324 to approximately ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access