Jump to content

StringFormat for currency


Recommended Posts

I am trying to left-pad currency with blank spaces, and the following example does work, but it uses StringFormat twice. Is there a way to accomplish this with just one use of StringFormat? Thanks for any help.

ConsoleWrite(StringFormat("%10s", StringFormat("%#.2f", "123")) & @CRLF)

Link to comment
Share on other sites

Another alternative:

ConsoleWrite(StringFormat("$%10.2f", 5) & @CRLF)
ConsoleWrite(StringFormat("$%10.2f", 50) & @CRLF)
ConsoleWrite(StringFormat("$%10.2f", 500.125) & @CRLF)

Output:

$      5.00
$     50.00
$    500.13

 

Edited by TheXman
Link to comment
Share on other sites

58 minutes ago, geller said:

I just wish the string-format documentation was more detailed...

You must read all the documentation carefully and look at the examples.  There are 10s of different formats shown in the example scripts.  Just open them and make some test.  But I suppose it is less demanding to ask here for help, right ?

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...