Data types in VB.net
By: Steven Holzner
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.
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 |
Archived Comments
1. This is winrar =)
View Tutorial By: Slugby at 2011-03-15 17:03:20
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net