geller Posted March 4, 2020 Share Posted March 4, 2020 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 More sharing options...
BigDaddyO Posted March 4, 2020 Share Posted March 4, 2020 you could try this ConsoleWrite(StringRight(" " & StringFormat("%#.2f", "123"), 10) & @CRLF) Link to comment Share on other sites More sharing options...
TheXman Posted March 4, 2020 Share Posted March 4, 2020 (edited) 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 March 4, 2020 by TheXman FrancescoDiMuro and dmob 2 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
geller Posted March 8, 2020 Author Share Posted March 8, 2020 Your solution works perfectly. I just wish the string-format documentation was more detailed... Link to comment Share on other sites More sharing options...
Nine Posted March 8, 2020 Share Posted March 8, 2020 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 ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now