On CBSSports.com: Mike Tyson's daughter dies in accident

Learn about VB6's Currency data type

Tags: Peter Aitken, data type, Microsoft Visual Basic 6.0, Visual Basic Tips Newsletter

  • Save
  • Print
  • Recommend
  • 2

Takeaway: 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!

  • Save
  • Print
  • Recommend
  • 2

What do you think?

White Papers, Webcasts, and Downloads

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

SmartPlanet

advertisement
Click Here