Jump to content

Recommended Posts

I'm getting better at it, but I still don't fully understand StringFormat().

I know that StringFormat("%.2d", 8.8) will produce '08'.

I also know that StringFormat("%.2f", 8.8) will produce '8.80'.

What i want to know is, how do I combine the two formats to get '08.80'?

In the example "%05.2f":-

"0" means to add leading 0's to make up total number of characters ( in this case is 5 or 6);

"5" or "6" is the total number of characters including the decimal point;

".2" is the precision or number of decimal places.

MsgBox(0, "Result", ' StringFormat("%05.2f %06.2f", 8.8, 8.8) = ' & StringFormat("%05.2f %06.2f", 8.8, 8.8))
Edited by Malkey
Link to comment
Share on other sites

This should do it. 5 is the minimum number of characters to output including the decimal poit.

$formatted = StringFormat("%.2f", 8.8)

Edit: Too slow at typing again :D

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...