int.TryParse

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ats@jbex

    #1

    int.TryParse

    I have a textbox on a web page that I want users to be able to enter a
    credit/debit card issue number if there is one. These numbers sometimes use
    a leading zero. If I use the int.TryParse function to ensure there are no
    alpha characters will it return false if the number is for instance 01 or
    02?

    TIA
    --
    ats@jbex

    When an old lady got hit by a truck
    I saw the wicked gleam in your eyes

    Adam and The Ants - Whip In My Valise
  • Bill McCarthy

    #2
    Re: int.TryParse

    Hi,

    "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.ukwrote in message
    news:9qd146lxi8 a2$.5k3firgqz7t o.dlg@40tude.ne t
    I have a textbox on a web page that I want users to be able to enter a
    credit/debit card issue number if there is one. These numbers
    sometimes use a leading zero. If I use the int.TryParse function to
    ensure there are no alpha characters will it return false if the
    number is for instance 01 or 02?
    >
    There's a couple of options. You can use Cint or IsNumeric but they both
    allow hex notation. IF you are using VB 2008 I would use this:

    If Textbox1.Text.A ll(Function(c) Char.IsDigit(c) ) Then

    Comment

    • Patrice

      #3
      Re: int.TryParse

      01 and 02 are integers so I don't see why TryParse wouldn't return true.
      Also it would be really easy to try this by yourself rather than asking...

      --
      Patrice

      "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.uka écrit dans le message de
      groupe de discussion : 9qd146lxi8a2$.5 k3firgqz7to.dlg @40tude.net...
      I have a textbox on a web page that I want users to be able to enter a
      credit/debit card issue number if there is one. These numbers sometimes
      use
      a leading zero. If I use the int.TryParse function to ensure there are no
      alpha characters will it return false if the number is for instance 01 or
      02?
      >
      TIA
      --
      ats@jbex
      >
      When an old lady got hit by a truck
      I saw the wicked gleam in your eyes
      >
      Adam and The Ants - Whip In My Valise

      Comment

      • rowe_newsgroups

        #4
        Re: int.TryParse

        On Sep 19, 11:15 am, "ats@jbex" <al...@allenjon es.NOSPAM.co.PL EASE.uk>
        wrote:
        I have a textbox on a web page that I want users to be able to enter a
        credit/debit card issue number if there is one. These numbers sometimes use
        a leading zero. If I use the int.TryParse function to ensure there are no
        alpha characters will it return false if the number is for instance 01 or
        02?
        >
        TIA
        --
        ats@jbex
        >
        When an old lady got hit by a truck
        I saw the wicked gleam in your eyes
        >
        Adam and The Ants - Whip In My Valise
        I would highly recommend you add one of the ASP.NET validation
        controls to the page to do some initial client-side checking. One
        strategy would be to use a Regex Validator to parse the input format,
        ensuring there are no alphabetic character or that the credit card
        number is in a valid format (xxxx-xxxx-xxxx-xxxx).

        As always, I highly recommend a product called Expresso for creating
        Regex expressions, it's free to use and can save you tons of time:



        Thanks,

        Seth Rowe [MVP]

        Comment

        • =?ISO-8859-1?Q?G=F6ran_Andersson?=

          #5
          Re: int.TryParse

          ats@jbex wrote:
          I have a textbox on a web page that I want users to be able to enter a
          credit/debit card issue number if there is one. These numbers sometimes use
          a leading zero. If I use the int.TryParse function to ensure there are no
          alpha characters will it return false if the number is for instance 01 or
          02?
          >
          TIA
          No. "01" or "02" will parse into integers without problems.


          --
          Göran Andersson
          _____
          Göran Anderssons privata hemsida.

          Comment

          • Gillard

            #6
            Re: int.TryParse

            have a look there







            "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.ukwrote in message
            news:9qd146lxi8 a2$.5k3firgqz7t o.dlg@40tude.ne t...
            I have a textbox on a web page that I want users to be able to enter a
            credit/debit card issue number if there is one. These numbers sometimes
            use
            a leading zero. If I use the int.TryParse function to ensure there are no
            alpha characters will it return false if the number is for instance 01 or
            02?
            >
            TIA
            --
            ats@jbex
            >
            When an old lady got hit by a truck
            I saw the wicked gleam in your eyes
            >
            Adam and The Ants - Whip In My Valise

            Comment

            • Scott M.

              #7
              Re: int.TryParse


              "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.ukwrote in message
              news:9qd146lxi8 a2$.5k3firgqz7t o.dlg@40tude.ne t...
              >If I use the int.TryParse function to ensure there are no
              alpha characters will it return false if the number is for instance 01 or
              02?
              I know one easy way to find out.


              Comment

              • Cor Ligthert[MVP]

                #8
                Re: int.TryParse

                Seth,

                I thought it was Google



                :-)

                Cor

                "rowe_newsgroup s" <rowe_email@yah oo.comschreef in bericht
                news:02be3703-f47c-4ecf-83de-06bd686581fd@26 g2000hsk.google groups.com...
                On Sep 19, 11:15 am, "ats@jbex" <al...@allenjon es.NOSPAM.co.PL EASE.uk>
                wrote:
                I have a textbox on a web page that I want users to be able to enter a
                credit/debit card issue number if there is one. These numbers sometimes
                use
                a leading zero. If I use the int.TryParse function to ensure there are no
                alpha characters will it return false if the number is for instance 01 or
                02?
                >
                TIA
                --
                ats@jbex
                >
                When an old lady got hit by a truck
                I saw the wicked gleam in your eyes
                >
                Adam and The Ants - Whip In My Valise
                I would highly recommend you add one of the ASP.NET validation
                controls to the page to do some initial client-side checking. One
                strategy would be to use a Regex Validator to parse the input format,
                ensuring there are no alphabetic character or that the credit card
                number is in a valid format (xxxx-xxxx-xxxx-xxxx).

                As always, I highly recommend a product called Expresso for creating
                Regex expressions, it's free to use and can save you tons of time:



                Thanks,

                Seth Rowe [MVP]


                Comment

                • ats@jbex

                  #9
                  Re: int.TryParse

                  On Sat, 20 Sep 2008 01:26:25 +1000, Bill McCarthy wrote:
                  Hi,
                  >
                  "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.ukwrote in message
                  news:9qd146lxi8 a2$.5k3firgqz7t o.dlg@40tude.ne t
                  >I have a textbox on a web page that I want users to be able to enter a
                  >credit/debit card issue number if there is one. These numbers
                  >sometimes use a leading zero. If I use the int.TryParse function to
                  >ensure there are no alpha characters will it return false if the
                  >number is for instance 01 or 02?
                  >>
                  >
                  There's a couple of options. You can use Cint or IsNumeric but they both
                  allow hex notation. IF you are using VB 2008 I would use this:
                  >
                  If Textbox1.Text.A ll(Function(c) Char.IsDigit(c) ) Then
                  Thanks I will give it a go.
                  --
                  ats@jbex

                  Those who died are justified, for wearing the badge, they're the chosen
                  whites
                  You justify those that died by wearing the badge, they're the chosen whites

                  Rage Against The Machine - Killing In The Name

                  Comment

                  • ats@jbex

                    #10
                    Re: int.TryParse

                    On Fri, 19 Sep 2008 08:44:15 -0700 (PDT), rowe_newsgroups wrote:
                    On Sep 19, 11:15 am, "ats@jbex" <al...@allenjon es.NOSPAM.co.PL EASE.uk>
                    wrote:
                    >I have a textbox on a web page that I want users to be able to enter a
                    >credit/debit card issue number if there is one. These numbers sometimes use
                    >a leading zero. If I use the int.TryParse function to ensure there are no
                    >alpha characters will it return false if the number is for instance 01 or
                    >02?
                    >>
                    >TIA
                    >--
                    >ats@jbex
                    >>
                    >When an old lady got hit by a truck
                    >I saw the wicked gleam in your eyes
                    >>
                    >Adam and The Ants - Whip In My Valise
                    >
                    I would highly recommend you add one of the ASP.NET validation
                    controls to the page to do some initial client-side checking. One
                    strategy would be to use a Regex Validator to parse the input format,
                    ensuring there are no alphabetic character or that the credit card
                    number is in a valid format (xxxx-xxxx-xxxx-xxxx).
                    >
                    As always, I highly recommend a product called Expresso for creating
                    Regex expressions, it's free to use and can save you tons of time:
                    >

                    >
                    Thanks,
                    >
                    Seth Rowe [MVP]
                    http://sethrowe.blogspot.com/
                    Thanks for this.
                    --
                    ats@jbex

                    Every year is the same
                    And I feel it again,
                    I'm a loser - no chance to win

                    The Who - I'm One

                    Comment

                    • ats@jbex

                      #11
                      Re: int.TryParse

                      On Fri, 19 Sep 2008 23:56:32 +0200, Gillard wrote:
                      have a look there

                      >

                      >

                      >
                      >
                      "ats@jbex" <allen@allenjon es.NOSPAM.co.PL EASE.ukwrote in message
                      news:9qd146lxi8 a2$.5k3firgqz7t o.dlg@40tude.ne t...
                      >I have a textbox on a web page that I want users to be able to enter a
                      >credit/debit card issue number if there is one. These numbers sometimes
                      >use
                      >a leading zero. If I use the int.TryParse function to ensure there are no
                      >alpha characters will it return false if the number is for instance 01 or
                      >02?
                      >>
                      >TIA
                      >--
                      >ats@jbex
                      >>
                      >When an old lady got hit by a truck
                      >I saw the wicked gleam in your eyes
                      >>
                      >Adam and The Ants - Whip In My Valise
                      Thanks
                      --
                      ats@jbex

                      The world is my expense
                      The cost of my desire
                      Jesus blessed me with its future
                      And I protect it with fire

                      Rage Against The Machine - Sleep Now In The Fire

                      Comment

                      Working...