QUICK QUESTION: How do I KEEP trailing zeros?

Posted on 2008-02-01
Medium Priority
Last Modified: 2013-12-26
I have an array Dimmed as Variant.  It has about 25 items in it, mostly integers, strings, and some currency.  I extracted the currency values and displayed them on a Form using CStr(arrArray(x)) but I noticed that the trailing zeros are stripped away.  How do I keep them?

For example:
51.50 becomes 51.5
51.00 becomes 51
51.23 remains 51.23

I want it so that:
51.50 remains 51.50
51.00 remains 51.00

How do I do this?
Question by:CoderBboy
  • 2
LVL 44

Accepted Solution

Arthur_Wood earned 200 total points
ID: 20803110
format (Value, "#,###.00")  this will keep 2 digits to the right of the decimal point, even if the rightmost is/would be 0)


Author Comment

ID: 20803180
The numbers range from 1 to 100,000,000.  How do I know how many # to use?
LVL 44

Expert Comment

ID: 20804283
the Format function is smart enough to know the #,###.00 means use the comma separator, regardless of the size of the number, be it 1,000.00 or 1,000,000,000.00 ...

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question