Printing Price to Text File and Appending Leading Zeros

cms370

Registered User.
Local time
Yesterday, 18:41
Joined
Jun 9, 2010
Messages
32
I am printing values from a table to a text file.

When printing the column for price, regardless of the actual price in the table, I need to make sure it fits into 10 digits which will then be printed to a text file.

For example:

The price in the table is $1.45.

When I print to the file, it needs to read as: 00000001.45

My first thought was to use the 'len" function to determine how many characters are in the price, then append based on this [append values =~ 10 - len(price)]. However, this does not work when I have a price of $1.00. For that instance, len gives the value of "1", when it should give "4".

Example code or a function that does this would be nice. Appreciate the help.
 
Format([fieldname], "00000000.00")
 
I just gave that a shot. For one of the records, the cash is "$4,474.5703". The result after using "Format(rs![Cash], "00000000.00")" is as follows: "000004474.57".

Not exactly what I am looking for. Does this make any sense?
 
Last edited:
Hold on you didn't mention four decimal places of cents.
Or have you mistyped the dot instead of a comma.
 
Ok...sorry about that. While I was posting this, I also added an SQL ROUND statement that formats the data two decimal places.

So the Cash field is actually just $4,474.57

I am now getting the correct answer. Thanks for your help. The plan I had was going to get messy really quick, but this simple 'Format' functions works very nicely.
 

Users who are viewing this thread

Back
Top Bottom