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. trimming a string

trimming a string

Scheduled Pinned Locked Moved C#
question
9 Posts 5 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.
  • R Offline
    R Offline
    robustm
    wrote on last edited by
    #1

    I have a string in which the numbers are entered and decimal point is also allowed. But, when the user enters a string for eg: 123,43 .....even this should be accepted as number and with "," is assumed as period "." , how can i do this.

    X P P 3 Replies Last reply
    0
    • R robustm

      I have a string in which the numbers are entered and decimal point is also allowed. But, when the user enters a string for eg: 123,43 .....even this should be accepted as number and with "," is assumed as period "." , how can i do this.

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      use Replace()

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

      1 Reply Last reply
      0
      • R robustm

        I have a string in which the numbers are entered and decimal point is also allowed. But, when the user enters a string for eg: 123,43 .....even this should be accepted as number and with "," is assumed as period "." , how can i do this.

        P Offline
        P Offline
        phannon86
        wrote on last edited by
        #3

        Nothing to do with trimming really, you want to look at String Replace[^]

        He who makes a beast out of himself gets rid of the pain of being a man

        1 Reply Last reply
        0
        • R robustm

          I have a string in which the numbers are entered and decimal point is also allowed. But, when the user enters a string for eg: 123,43 .....even this should be accepted as number and with "," is assumed as period "." , how can i do this.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Use a NumericUpDown

          L 1 Reply Last reply
          0
          • P PIEBALDconsult

            Use a NumericUpDown

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            for five-digit numbers such as 123,43 :confused:

            Luc Pattyn [Forum Guidelines] [My Articles]


            This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


            P 1 Reply Last reply
            0
            • L Luc Pattyn

              for five-digit numbers such as 123,43 :confused:

              Luc Pattyn [Forum Guidelines] [My Articles]


              This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              NumericUpDown, with two decimal places. I would expect the current culture would determine which decimal delimiter is in use (though I've never tried it).

              L 1 Reply Last reply
              0
              • P PIEBALDconsult

                NumericUpDown, with two decimal places. I would expect the current culture would determine which decimal delimiter is in use (though I've never tried it).

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                PIEBALDconsult wrote:

                I would expect the current culture would determine which decimal delimiter is in use

                I trust it does, but the way I understood it the OP wanted both period and comma to act as decimal point (which I fully understand, the lack of a single international standard way of using periods and comma's is troublesome). my point however was the up/down doesn't seem very useful for long numbers: when the increment corresponds to the last digit, it takes forever to up/down the leading digits; and when it does not, the last digit(s) are not affected by it. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                P 1 Reply Last reply
                0
                • L Luc Pattyn

                  PIEBALDconsult wrote:

                  I would expect the current culture would determine which decimal delimiter is in use

                  I trust it does, but the way I understood it the OP wanted both period and comma to act as decimal point (which I fully understand, the lack of a single international standard way of using periods and comma's is troublesome). my point however was the up/down doesn't seem very useful for long numbers: when the increment corresponds to the last digit, it takes forever to up/down the leading digits; and when it does not, the last digit(s) are not affected by it. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  Yes, but I tend to just type the number into the NumericUpDown anyway.

                  L 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Yes, but I tend to just type the number into the NumericUpDown anyway.

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    I see, I'm still use TextBoxes for that, with some masking if appropriate. The NUD does a lot of masking (and limit checking) but seems to accept multiple decimal points, so it may still need validation. And I wish there were a way to hide the up/down arrows... :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                    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