Marc Posted February 6, 2004 Posted February 6, 2004 Hi, just a question about the stringformat command: is it possible to achive the... ehrm, dunno the correct word, in german we would call it "tausenderzeichen"? I have a value, let's say 123456790. To make reading easier, I want to put it out as 1.234.567.890 (or 1,234,567,890 if you prefer). Can this be achieved using stringformat? Just curious, already wrote my own function to achieve this goal. Only want to know whether I wrote this function for nothing or not cu Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
Bartokv Posted February 6, 2004 Posted February 6, 2004 I believe that string formatting was in a previous discussion, however I don't remember if anybody made any scripts to do the formatting. Below is a very simple string formatting function that I made. You should be able to modify it to whatever format you desire: MsgBox(0, "Test", FormatNumber("1234567890", ".", 3)) Exit Func FormatNumber($RawNum, $SepChar, $SegLen) $ComNum = "" If $SepChar = "" Then $SepChar = "," If $SegLen < 0 Then $SegLen = 3 While (StringLen($RawNum) > $SegLen) $RawNum_len = StringLen($RawNum) $ComNum = $SepChar & StringMid($RawNum, $RawNum_len - ($SegLen - 1), $SegLen) & $ComNum $RawNum = StringTrimRight($RawNum, $SegLen) Wend $ComNum = $RawNum & $ComNum return $ComNum EndFunc Hope this helps!
Marc Posted February 7, 2004 Author Posted February 7, 2004 Interesting function But, as I said: already wrote my own function. Just wanted to know if it could be done just using StringFormat cu Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
Bartokv Posted February 7, 2004 Posted February 7, 2004 Oops! Sorry, I didn't read the last line of your post before I made my response. . . :iamstupid:
jpm Posted February 7, 2004 Posted February 7, 2004 Interesting function But, as I said: already wrote my own function. Just wanted to know if it could be done just using StringFormat cuMarcI think so.You have to use the flag field see the doc. The doc is a cut and paste from windows/C spec perhaps we should put more exampleJust exercise you will see the power of StringFormat
Marc Posted February 8, 2004 Author Posted February 8, 2004 More examples in the docu would be nice Tried to figure it out using the current docu, but it did not really work out the way I wanted. Perhaps it's my fault, because I simply hate C/C++ language.... Next time better luck... Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)
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