Sign in to follow this  
Followers 0
Marc

Stringformat Question

6 posts in this topic

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 :whistle:

cu

Marc


It's my job to comfort the disturbed and to disturb the comfortable.

Share this post


Link to post
Share on other sites



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! :whistle:

Share this post


Link to post
Share on other sites

Interesting function :whistle:

But, as I said: already wrote my own function. Just wanted to know if it could be done just using StringFormat B)

cu

Marc


It's my job to comfort the disturbed and to disturb the comfortable.

Share this post


Link to post
Share on other sites

Oops! Sorry, I didn't read the last line of your post before I made my response. B)

. :whistle: .

:iamstupid:

Share this post


Link to post
Share on other sites

Interesting function  :whistle:

But, as I said: already wrote my own function. Just wanted to know if it could be done just using StringFormat  B)

cu

Marc

I 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 example

Just exercise you will see the power of StringFormat

Share this post


Link to post
Share on other sites

More examples in the docu would be nice B)

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

Next time better luck...


It's my job to comfort the disturbed and to disturb the comfortable.

Share this post


Link to post
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
Sign in to follow this  
Followers 0