int.TryParse

  • Thread starter Thread starter ats@jbex
  • Start date Start date
A

ats@jbex

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
 
Hi,

ats@jbex said:
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.All(Function(c) Char.IsDigit(c)) Then
 
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:

http://www.ultrapico.com/Expresso.htm

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
ats@jbex said:
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.
 
ats@jbex said:
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.
 
Seth,

I thought it was Google

http://javascript.internet.com/forms/val-credit-card.html

:-)

Cor

"rowe_newsgroups" <[email protected]> schreef in bericht
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:

http://www.ultrapico.com/Expresso.htm

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
Hi,



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.All(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
 
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:

http://www.ultrapico.com/Expresso.htm

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
 
Back
Top