Data types in VB.net

By Steven Holzner Viewed: 31743 times Emailed: 185 times Printed: 216 times Bookmark and Share



It's time to create a new variable—but what type should you use? For that matter, exactly what kinds of variable types are there and what do they do? Even if you remember what types there are, you probably won't remember the range of possible values a particular variable type allows.

There is a wide range of data types. The Visual Basic variable types appear in Table below for reference, making selecting the right type a little easier. Note that the Single and Double types handle floating point values, which the Integer types (such as Short, Integer, and Long) do not; these names are short for single precision floating point and double precision floating point. You might also notice that there are some new types in VB .NET that weren't in VB6, like Char, and that some other types, like Currency or Variant, are gone. Note in particular the Boolean data type, which takes values like True or False only—also called logical values.

 

 

 

Visual Basic data types.

Type

Storage size

Value range

Boolean

2 bytes

True or False

Byte

1 byte

0 to 255 (unsigned)

Char

2 bytes

0 to 65535 (unsigned)

Date

8 bytes

January 1, 0001 to December 31, 9999

Decimal

16 bytes

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

Double

8 bytes

-1.79769313486231E+308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486231E+308 for positive values

Integer

4 bytes

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

Long

8 bytes

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

Object

4 bytes

Any type can be stored in a variable of type Object

Short

2 bytes

-32,768 to 32,767

Single

4 bytes

-3.402823E to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E for positive values

String

Depends on implementing platform

0 to approximately 2 billion Unicode characters

User-Defined Type

(structure)

Sum of the sizes of its members. Each member of the structure has a range

determined by its data type and independent of the ranges of the other members




Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:


Enter Code:
The Captcha image

Latest Tutorials

[2009-03-22]Handling Timer Events - and Creating an Alarm Clock in VB.net
[2009-03-22]Creating Menus in Code using VB.net
[2009-03-22]Creating Context Menus in Code using VB.net
[2009-03-22]Creating Tree Views in Code using VB.net
[2009-03-22]Creating List Views in Code using VB.net
[2009-03-16]Send SMS using VB code
[2009-02-27]Creating a Windows Service in VB.net
[2009-02-27]Creating a Windows Service Installer in VB.net
[2009-02-24]OleDbConnection class in VB.net
[2009-02-24]OleDbDataAdapter class in VB.net
[2009-02-24]DataSet Class in VB.net
[2009-02-24]DataTable Class in VB.net
[2009-02-24]DataRow Class in VB.net
[2009-02-22]Chat Server in VB.net
[2009-02-22]A tutorial on Chat Server and Chat Client in VB.net

More Latest News

Most Viewed Articles (in last 30 days)
For Loop in VB.net
Send SMS using VB code
While Loop in VB.net
Your first VB.NET Crystal Reports - A step by step guide
The Select Case statement in VB.net
Using Select Case in VB.net
Sub Procedures and Functions in VB.net
How to export from DataGridView to excel using VB.net
Arrays and Dynamic Arrays in VB.net
If…Else Statements in VB.net
Insert cell data in an Excel file using OLEDB in VB.net
Client Socket Program sample in VB.net
Handling Timer Events - and Creating an Alarm Clock in VB.net
Chat Server in VB.net
How to send email using VB.NET code
Most Emailed Articles (in last 30 days)
For Loop in VB.net
If…Else Statements in VB.net
Send SMS using VB code
While Loop in VB.net
The Option and Imports Statements in VB .NET
What's New in VB .NET? A comparison of VB vs VB.net
Visual Basic Statements
Using Select Case in VB.net
For Each…Next Loop in VB.net
The Select Case statement in VB.net
Do Loop in VB.net
“Using If with And” and Comparing two integers using If
What is .NET Framework and the Common Language Runtime?
Data types in VB.net
Arrays and Dynamic Arrays in VB.net