Results 1 to 6 of 6

Thread: Decimal Places

  1. #1
    Addicted Member Skeen's Avatar
    Join Date
    Jul 00
    Location
    Abingdon, Oxon
    Posts
    138

    Talking

    Hello everyone,

    This probably sounds really stupid, but can anyone tell me how to fromat numbers into two decimal places. I'm really stuck on this one - never had to do it before, and all the books I've seen just describe the ecimal data type.

    Cheers

    Skeen
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 00
    Location
    Hastings
    Posts
    696
    Hi skeen
    sorry I didn't reply by ICQ (few problems with my computer)

    To format numbers you use FormatNumber (wow, now that's uncanny)

    here it is(taken from msdn)

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

    Arguments
    Expression

    Required. Expression to be formatted.

    NumDigitsAfterDecimal

    Optional. Numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.

    IncludeLeadingDigit

    Optional. Tristate constant that indicates whether or not a leading zero is displayed for fractional values. See Settings section for values.

    UseParensForNegativeNumbers

    Optional. Tristate constant that indicates whether or not to place negative values within parentheses. See Settings section for values.

    GroupDigits

    Optional. Tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the control panel. See Settings section for values.

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3
    Addicted Member Skeen's Avatar
    Join Date
    Jul 00
    Location
    Abingdon, Oxon
    Posts
    138

    Smile Thanx Ian

    Cheers Ian, I havn't got the MSDN library, wish I had,
    Thanks again

    Cheers 'n' beers
    skeen
    "It wasn't the booze that made me snooze, It was the Gin that did me in!"

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 00
    Location
    Hastings
    Posts
    696
    If you go to http://msdn.microsoft.com

    You can get to everything and a lot more. Takes a while sometimes to find what your looking for, but it is the number one resource for any thing microsofty

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 99
    Location
    Singapore
    Posts
    524
    Do you think u can use Format Function for ASP / VB Script ??? Isn't it just for VB Reference ??? Not for ASP / VB Scripting ???
    I've tried before, nd still can't use it...

    Till now, I'm still using Round Function for formatting my decimal number.
    And I'm still confuse about formatting my number into hundreds, thousands, million, etc...
    or to format date...

    Do you know how ???

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  6. #6
    Frenzied Member monte96's Avatar
    Join Date
    Sep 00
    Location
    Somewhere in AZ
    Posts
    1,379
    FormatNumber will not round. It will truncate. Depends on your needs I guess.

    You can't use 'Format' in VBScript- It's FormatCurrency, FormatNumber, and FormatDateTime

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    monte96_@hotmail.com
    monte96@vbgarage.com


    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
  •