Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to format a String as Currency

Status
Not open for further replies.

nonturbo

IS-IT--Management
Aug 27, 2001
78
US
I know I've seen somewhere a way to format a string. Right now I have (for example) MyString = "Total: " & MyTotal

However, MyTotal is showing up as 13.2345634545E02, where I'd just like it to show up as $0.13. Thanks in advance for helping out with such an easy question! :)

Also..

Does anyone know how to resize a label on a form to Fit, programmatically? You know, in the IDE, Format > Size > To Fit. Thanks again!

 
Hi,

So you are saying that myTotal is a 100 time bigger then it must be. Did you miscalculate or is the value correct?
If it is correct and if it is always 100 times bigger then the solution should be simple.
You could try this

MyString = "Total: " & CCur(MyTotal/100)

For the label you could try this

Label1.AutoSize=True
 
If I just have myTotal as a label, and set the format to currency, the value comes out fine. The problem is that the value of myTotal is the product of a complex string of calculations, with myTotal being very precise. For example, when I'm just looking for $0.03, it will print out 33.3536466442408804598E02, or something to that effect. CCur(MyTotal) is what I was looking for. Thanks.

As far as the label goes, the .AutoSize property causes the following crash (im using Access 2002): Compile Error: Method or data member not found.
 
So, you have a floating point number and want to round or truncate. You could move it to a currency field and additionally apply formatting. Also, you could try formatting the mytotal field. Look up Format in Help.

Dim myfield as currency
myfield = mytotal
 
That seems like it'll work too. Any ideas for the label sizing problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top