Results 1 to 5 of 5

Thread: Formating a string of numbers

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149

    Question

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

  2. #2
    Junior Member
    Join Date
    Sep 2000
    Posts
    25

    Thumbs up dude....

    I believe it would be

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

    The 0 makes sure at least a zero is printed....
    Jim Hubbard
    • VB
    • ASP
    • MS SQL Server

    Hubbard Software Corporation
    [email protected]

  3. #3
    New Member
    Join Date
    Dec 2000
    Location
    Pune,India
    Posts
    5

    Lightbulb Check this out..

    hi,
    write ur code as,

    stringname = Format(stringname, "#,###,###")
    Kaustav Ghosh
    s/w Programmer and Developer
    Engineering Division
    [email protected]
    Versaware Technologies (India) Pvt. Ltd.


  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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.


    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Sorry, I guess I could have also just given you an answer:

    Code:
    StringName = FormatNumber(StringName,0,,,-1)
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width