Learn about VB6's Currency data type

Visual Basic 6's Currency data type is specifically designed to hold data that represents money amounts. Discover several advantages to using the Currency data type.

Many VB6 programmers automatically use the Single data type for holding data that represents money amounts. You should be aware that the Currency data type is, as the name implies, specially designed for this purpose and offers some advantages.

Currency is a fixed-point data type, as opposed to the floating-point Single. In other words, it is always accurate to a specific number of decimal places, four in this case. While the Single type can represent many more decimal places, these are not needed in Currency calculations and, in fact, can introduce rounding errors. These errors are small but can have an effect on overall accuracy.

The Currency data type is actually an integer type internally. In use, it is scaled by a factor of 10,000 to give four digits to the right of the decimal point. It permits up to 15 digits to the left of the decimal point, resulting in a range of approximately -922,337,000,000,000 to +922,337,000,000,000. An individual type Currency variable takes up 8 bytes of memory, compared to 4 bytes for Single.

Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!

Editor's Picks

Free Newsletters, In your Inbox