.Net, ASP.NET, Various Languages, VB 6.0, VB.NET

VB Data Types VB6/VB.net – Comparison Chart

Recently I was looking into some old VB6 code and for my own reference decided I’d put together a simple summary of how VB6 data types map to .NET data types.

This is nothing new, but I thought it would be handy to have a quick comparison chart available. I obtained the information for this chart directly from the MSDN VB6 and MSDN VB.NET documentation pages (see below for the reference links).

Here is the summary:

VB 6.0 VB 6.0 Bytes VB 6.0 Range VB.NET VB.NET Bytes VB.NET Range
Boolean  True/False   True/False Boolean  True/False   True/False
Byte  1  0-255 Byte  1  0-255
 —  — Char  2  0-65535
Date  8  0:00:00 0001-01-01 – 11:59:59 9999-12-31 Date  8  0:00:00 0001-01-01 – 11:59:59 9999-12-31
Currency  8  -922,337,203,685,477.5808 to 922,337,203,685,477.5807 Decimal  16  0 to +/-79,228,162,514,264,337,593,543,950,335 or  0 to +/-7.9228162514264337593543950335
Decimal  14 Decimal  16
Double  8  -1.79769313486231E308 to
-4.94065645841247E-324 or  4.94065645841247E-324 to 1.79769313486232E308
Double  8  -1.79769313486231570E+308 through -4.94065645841246544E-324 or 4.94065645841246544E-324 through 1.79769313486231570E+308
Integer  2  -32,768 – 32,767 Integer  4  -2,147,483,648 – 2,147,483,647
Long  4  -2,147,483,648 – 2,147,483,647 Long  8  -9,223,372,036,854,775,808 – 9,223,372,036,854,775,807
Variant  4 22 bytes + string length Object  4  4 bytes on 32, 8 on 64 bit platform (+ the cost of the element being held by the object)
 — SByte  1  -128 through 127
 — Short  2  -32,768 through 32,767
Single  4 Single  4  -3.4028235E+38 to -1.401298E-45, 1.401298E-45 to 3.4028235E+38
String  Variable/Fixed  10 bytes + string length String  Variable  0- 2 billion Unicode characters
 — UInteger  4  0 – 4,294,967,295
 — ULong  8  0 -18,446,744,073,709,551,615
 — UShort  2  0 – 65,535

If you create a VB6 array, then the array itself will take 20 bytes plus 4 bytes for each dimension. Then any data added to the array will occupy the size of the element times the number of added elements (ie: 6 dates added to a 1-dimensional array would be (6 * 8 )+ 20 + 4 = 52 bytes used.

Alternately if you create a VB.NET array, the cost is 12 bytes + 8 bytes for each dimension on a 32 bit system, and 24 + 16 on a 64 bit system.
References:

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s