Jump to content

Recommended Posts

Posted

I'm having some trouble while using the StringFormat.

visual Basic for example is as easy as

Dim nValue as String

nValue = 10000

Text1.text = Format("###,###", nValue)

Where the text in Text1 would become 10,000 instead of 10000 all together.

However the StringFormat isn't working as i was hoping it would.

any ideas would greatly be appreciated.

Greetz Blinko

Posted (edited)

Hi!

Maybe something like this?

MsgBox(0,"10000",_Format("###,###",",",10000))

; Author monoceres
Func _Format($pattern,$delimiter,$number)
    $number=String($number)
    Local $answer
    $array=StringSPlit($pattern,$delimiter)
    For $i=Ubound($array)-1 To 1 Step -1
        $count=StringLen($array[$i])
        $answer=StringRight($number,$count)&$delimiter&$answer
        $number=StringTrimRight($number,$count)
        If StringLen($number)=0 Then ExitLoop
    Next
    $answer=StringTrimRight($answer,1)
    If StringLen($number)>0 Then
        $answer=$number&$answer
    EndIf
    return $answer
EndFunc

:)

Edited by monoceres

Broken link? PM me and I'll send you the file!

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
  • Recently Browsing   0 members

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