CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Posts
    128

    displaying value with Comma

    hi,

    how do i display a value with a comma

    eg:

    double value = 100000;

    How do i save this number like 1,00,000.00 in order to save it to database.

    please help.
    Last edited by dskp; August 24th, 2011 at 08:19 AM.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: displaying value with Comma

    Quote Originally Posted by dskp View Post
    hi,

    how do i display a value with a comma

    eg:

    double value = 100000;

    How do i save this number like 1,00,000.00 in order to save it to database.

    please help.
    1) What do you mean by "display a value"? Numeric values are not strings, or is the number already a string and you want to put commas in it?

    2) Why do you want to save a formatted number to a database? What's wrong with just saving the unformatted number, and then let the program format the number any way it sees fit?

    3) Related to 2), what if the locale doesn't use commas in numbers? For example, many European countries do not use comma for separating millions, thousands, etc. They use the "." character. That's why it doesn't make sense saving formatted number to a database.

    Regards,

    Paul McKenzie

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: displaying value with Comma

    If you save it to a numeric type field in a database, you don't want punctuation.

    If you want commas and periods, as far as I know, you need to insert them yourself.

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

Featured