VB.NET:
Data Types:
Boolean
Byte (0 to 255)
Char
Date
String
Decimal
Object
Short (-32,768 to 32,767)
Integer (-2,147,483,648 to 2,147,483,647)
Long (larger whole numbers)
Single (floating point accuracy to 6 digits)
Double (floating point accuracy to 14 points)
Data Types – Memory Usage:
Boolean – 2 bytes
Byte – 1 byte
Char – 2 bytes
Date – 8 bytes
String – varies
Decimal – 16 bytes
Object – 4 bytes
Short – 2 bytes
Integer – 4 bytes
Long – 8 bytes
Single – 4 bytes
Double – 8 bytes
Data Types – Prefixes:
Boolean – bln
Byte – byt
Char – chr
Date – dat
String – str
Decimal – dec
Object – depends on type of object
Short – sht
Integer – int
Long – lng
Single – sng
Double – dbl
Type-Declaration Characters:
Append single character to the end of the Constant's Value to indicate the Data Type
Short – S
Integer – I
Long – L
Decimal – D
Single – F
Double – R
Compiler Options:
Explicit - Variables must be declared before usage
Strict - Type conversions are forced which provides more accurate results
Both should be turned on at the top of every module and class.
Variables – Scope & Lifetime:
Global/Public (use sparingly and cautiously)
-Available to all modules and procedures of Project
-Initialized at start of Project
Module/Private (Form)
-Available to one module and all procedures within that module
-Initialized 1st time the Form is loaded
Local
-Available only to the procedure it is declared in
-Initialized every time the Procedure runs
Block (Try/Catch, For/Next, Do/While, etc)
-Available only to the block of code inside a procedure it is declared in
-Initialized every time the Procedure runs
Scope Declaring & Naming:
Global/Public g prefix
-Declare in General Declarations as Public
-Public/Friend gstrName as String
Module/Private m prefix
-Declare in Module’s General Declarations as Private
-Private mstrName as String
Local no prefix required
-Declare in Event Procedures
-Dim strName as String