PDA

Click to See Complete Forum and Search --> : Formating a string of numbers


hurgh
Dec 6th, 2000, 11:36 PM
Hi,
Could anyone help me with formatting a string of numbers.

What I have is i have gotten a string of numbers out of a DB that looks like this say 123456789 and I would like to format them like this 123,456,789

How do I do this in vbscript, is it something like

format("#,###,###", StringName)

Any help would be great

-|- Hurgh -|-

dilama
Dec 6th, 2000, 11:46 PM
I believe it would be

String = format(number,"###,###,##0")

The 0 makes sure at least a zero is printed....

kaustavg
Dec 7th, 2000, 12:07 AM
hi,
write ur code as,

stringname = Format(stringname, "#,###,###")

monte96
Dec 7th, 2000, 09:14 AM
VBScript does not support the Format function.

You will need to use the FormatNumber function which has the following syntax:

FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

The last three parameters use the following:
-1 = True
0 = False
-2 = Default, Use Regional Settings.

monte96
Dec 7th, 2000, 09:20 AM
Sorry, I guess I could have also just given you an answer:


StringName = FormatNumber(StringName,0,,,-1)