Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reformating decimal numbers

Reformating decimal numbers

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Charith Jayasundara
    wrote on last edited by
    #1

    Hi, I am working with a VS2005 windows application. There are some text boxes that are used for entering decimal numbers. If user enter -1234567.8, I want to reformat it as -1,234,567.80 How can I do it, I tried to use MaskText box but could :( Thanks you! Harsh

    jayasshc

    C 1 Reply Last reply
    0
    • C Charith Jayasundara

      Hi, I am working with a VS2005 windows application. There are some text boxes that are used for entering decimal numbers. If user enter -1234567.8, I want to reformat it as -1,234,567.80 How can I do it, I tried to use MaskText box but could :( Thanks you! Harsh

      jayasshc

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can use string.Format to format a number, or you can overload the textbox itself to give you the format you want, by handling events when the text changes, and reformating it. You're better off formating it when the focus leaves the textbox tho

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      C 2 Replies Last reply
      0
      • C Christian Graus

        You can use string.Format to format a number, or you can overload the textbox itself to give you the format you want, by handling events when the text changes, and reformating it. You're better off formating it when the focus leaves the textbox tho

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        C Offline
        C Offline
        Charith Jayasundara
        wrote on last edited by
        #3

        Could you please give me an example? Thanks!

        jayasshc

        1 Reply Last reply
        0
        • C Christian Graus

          You can use string.Format to format a number, or you can overload the textbox itself to give you the format you want, by handling events when the text changes, and reformating it. You're better off formating it when the focus leaves the textbox tho

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          C Offline
          C Offline
          Charith Jayasundara
          wrote on last edited by
          #4

          Hi, I got it, could find a good example. Thank you very much! Harsh

          jayasshc

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups