int.TryParse

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
 
B

Bill McCarthy

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
 
R

rowe_newsgroups

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/
 
G

Göran Andersson

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.
 
S

Scott M.

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.
 
C

Cor Ligthert[MVP]

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/
 
A

ats@jbex

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
 
A

ats@jbex

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top