Data types

The data types used across all languages are basically the same, but the terms differ in some cases.

One important difference is between classic VB(A) and the .NET languages. As time goes on, we use larger and larger numbers. So large, sometimes, that the older languages have no support for them. .NET has added support and in doing so, changed the definitions for some of the numeric terms. For example, Long in the classic VB languages is Integer (int) in .NET.

Com-VB VB.NET C# .NET Framework (all lang.) expected value
String String string String VBA: a string of ANSI characters.
NET: a string of Unicode-characters
(careful! Many older properties require -1 instead of 1 oder True)
Boolean bool Boolean True / False
-1 OR 1 / 0
Byte Byte byte Byte 0 to 28-1
Integer ShortInteger short Int16 -215 to 215-1
Long Integer int Int32 -231 to 231-1
no equivalent Long long Int64 -264 to 264-1
Single Single float Single ±(~10-45 to 1038)
Double Double double Double ±(~10-324 to 10308)
exists, but can’t be used directly by VBA. Decimal decimal Decimal ±(~10-28 to 1028)
Variant no  exact equivalent. Closest match: Object no  exact equivalent. Closest match: object no  exact equivalent. Closest match: Object The exact type is unknown at design time, only at runtime.
no equivalent no equivalent var no equivalent The compiler looks up the type based on the object being assigned.
no equivalent no equivalent dynamic no equivalent The type is calculated at runtime.

Leave a Reply