1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how 123456 become 123,456 ?

Discussion in 'C#' started by JJnacy, Apr 12, 2008.

  1. #1
    How to make 123456789 become 123,456,789 ?
    Adding "," so I can print 123,456,789 out.

    Thank you.
     
    JJnacy, Apr 12, 2008 IP
  2. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you provide some more detail on what you are trying to do? Such as the source of the numerals, how you atrying to display them, etc.
     
    Jhar, Apr 12, 2008 IP
  3. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    example from Free Calendars
    Selected Year:[ 3008] Month:[ 04] Date:[ 12] Weekday:[ Wednesday] Total days since 0001/01/01: [1098409]

    Any easy way to make [1098409] become [1,098,409] ?
    If a big number can have "," then it will be more easy to read.

    Thanks
     
    JJnacy, Apr 12, 2008 IP
  4. Jhar

    Jhar Peon

    Messages:
    318
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Use the following: String.Format("{0:#,###}", INPUTTEXT) to format your output with ","s.

    Here is a working example to help you integtrate with your page:

    <script language="C#" runat="server">
    void Page_Load(Object sender, EventArgs e)
    {

    int totalDays = 1098307;
    lbltotalDays.Text = String.Format("{0:#,###}", totalDays);
    }
    </script>
    <head>
    </head>
    <html>
    <body>
    Total days since 0001/01/01:
    <asp:label id="lbltotalDays" runat="server" />
    </body>
    </html>
     
    Jhar, Apr 12, 2008 IP
    JJnacy likes this.
  5. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Jhar,

    Your script language="C#" and aspx is working yet how do I save the result "1,098,307" to DB table?
     
    JJnacy, Apr 12, 2008 IP
  6. InfoSmith

    InfoSmith Peon

    Messages:
    884
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    a default function in vb script call FormatNumber
     
    InfoSmith, Apr 13, 2008 IP
    JJnacy likes this.
  7. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nice one. Thanks.
    Reps all added.
     
    JJnacy, Apr 13, 2008 IP