Exploring the data types in Visual Basic.
| Data Group | Data Type | Prefix | Values | Size (bytes) |
|---|---|---|---|---|
| bln | Boolean | bln/b | True or False, Yes or No, etc. | 2 |
| byt | Byte | byt | 0 to 255 | 1 |
| int | Integer | int/i | +/-32,768 | 2 |
| Long [integer] | lng/l | +/-2,147,483,648 | 4 | |
| fp | Single [-precision floating point] | sng | +/-3.402823E38 to +/-1.401298E-45 | 4 |
| Double [-precision floating point] | dbl | +/- 4.94065645841247D324 to +/-1.79769313486232D-308 | 8 | |
| mny | Currency | cur | +/-$922,337,203,685,477.5808 | 8 |
| dtm | Date [-time] | dtm/d | January 1, 100 to December 31, 9999 | 8 |
| str | String (fixed length) | str/s | 1 to roughly 65,400 | Length of String |
| String (variable length) | str/s | 0 to roughly 2 billion | 10 + Length of String | |
| spec | Variant (with numbers) | vnt/v | any value up to double that of the double data type | 16 |
| Object | obj | an object reference either in or out of the application | 4 | |
| Err Object | err | Variable | ||
| Collection Object | col | 16 * No. in Collection | ||
| User Defined | udt | Variable |
Empty. A value if the variant is brand new and has never been assigned a value. This is not the same a 0 (zero), zero-length string (""), or space ( ).Null. Usually indicates unknown or missing data. All other data types will return an error if assigned a null value.Error. Special values returned by passing real numbers to the CVErr function.[Public | Private] Type NameOfUDT UDTProperty1 As DataType UDTProperty1 As DataType ... UDTPropertyN As DataType End Type
Type MyDogUDT
DogName As String
CollarColor() As Sring
Age As Integer
End Type
Dim udt1 As MyDogUDT udt1.DogName = "Rover"
[Public | Private] Enum NameOfUDT EnumMember1 [= LongExpression ] EnumMember1 [= LongExpression ] ... EnumMemberN [= LongExpression ] End Enum
Enum Stooge
KMoe = 2 'Otherwise 0 by default.
KLarry 'This is 3, ie 1 greater than the preceding.
KCurly = 1 'This would have been 4.
End Enum
Dim myStooge As Stooge myStooge = KCurly MsgBox "Curly is number " & CStr(myStooge)
Page Modified: (Hand noted: 2007-09-20 19:43:52Z) (Auto noted: 2007-11-17 06:37:24Z)