Datatypes of VB.NET


Data Type determines which type of value can be stored in the variable. You can specify Data Type for a variable at the time of declaring a variable.
Data types supported by VB.NET are classified into following categories:

(1)Numeric Data Types


DataType Byte Purpose

Short

2

It is used to store 2 Byte integer value. Default value is 0.

Integer

4

It is used to store 4 Byte integer value. Default value is 0.

Long

8

It is used to store 8 Byte integer value. Default value is 0.

Single

4

It is used to store floating point value. It is normally used to store single precision floating point numbers which has less accuracy. Default value is 0.

Double

8

It is used to store floating point value. It is normally used to store double precision floating point numbers which has more accuracy. Default value is 0.

Decimal

16

It is used to store floating point value. It is normally used to store floating point numbers that require greater number of significant digits. It supports up to 29 significant digits. It is generally used in financial calculations. Default value is 0.


     

(2)Character and String Data Type


DataType Byte Purpose

Char

2

Character data type is used to store only single character that is enclosed between double quotation mark.

String

Up to 2 billion characters

String Data Type is used to store textual information such as letters, digit and some special characters. It is a group of characters enclosed between double quotation mark.


(3) Byte Data Type


DataType Size Purpose

Byte

1

Byte data type is used to store binary data such as binary file, image, sound etc… It is unsigned Byte data type. Default value of Byte data type is 0.

SByte

1

SByte data type is used to store binary data such as binary file, image, sound etc…It is signed Byte data type. Default value of Byte data type is 0.


(4) Boolean Data Type


DataType Size Purpose

Boolean

2

Boolean datatype is used to store true or false value. Default value of Boolean variable is FALSE. You can also assign integer value to Boolean variable. Any Non-Zero value is considered as TRUE and zero is considered as FALSE.


(5) Date Data Type


DataType Size Purpose

Date

8

Date datatype is used to store Date and Time value.
You can assign values to Date variable using one of the following methods:
CurrentDate = Now.Date          ‘assign current system date
CurrentDate = #08/03/1982#    ‘assign user specific date


(6) Object Data Type


DataType Size Purpose

Object

8

Object data type can store value of any type. You can store numeric, byte, Boolean, floating point or string value in this type of variable. It is the default type of the variable. It means if you don’t declare the variable then the default Data Type for that variable is object.


Download Projects


Download Programs