473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

int.TryParse

ats
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
Sep 19 '08 #1
10 3662
Hi,

"ats@jbex" <al***@allenjones.NOSPAM.co.PLEASE.ukwrote in message
news:9q****************************@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?
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

Sep 19 '08 #2
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" <al***@allenjones.NOSPAM.co.PLEASE.uka écrit dans le message de
groupe de discussion : 9q****************************@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

Sep 19 '08 #3
On Sep 19, 11:15*am, "ats@jbex" <al...@allenjones.NOSPAM.co.PLEASE.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:

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

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Sep 19 '08 #4
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
_____
http://www.guffa.com
Sep 19 '08 #5
have a look there
http://en.wikipedia.org/wiki/Credit_card_numbers

http://en.wikipedia.org/wiki/ISO_7812

http://en.wikipedia.org/wiki/Luhn_algorithm
"ats@jbex" <al***@allenjones.NOSPAM.co.PLEASE.ukwrote in message
news:9q****************************@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
Sep 19 '08 #6

"ats@jbex" <al***@allenjones.NOSPAM.co.PLEASE.ukwrote in message
news:9q****************************@40tude.net...
>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.
Sep 20 '08 #7
Seth,

I thought it was Google

http://javascript.internet.com/forms...edit-card.html

:-)

Cor

"rowe_newsgroups" <ro********@yahoo.comschreef in bericht
news:02**********************************@26g2000h sk.googlegroups.com...
On Sep 19, 11:15 am, "ats@jbex" <al...@allenjones.NOSPAM.co.PLEASE.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:

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

Thanks,

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

Sep 20 '08 #8
ats
On Sat, 20 Sep 2008 01:26:25 +1000, Bill McCarthy wrote:
Hi,

"ats@jbex" <al***@allenjones.NOSPAM.co.PLEASE.ukwrote in message
news:9q****************************@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?

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
Sep 23 '08 #9
ats
On Fri, 19 Sep 2008 08:44:15 -0700 (PDT), rowe_newsgroups wrote:
On Sep 19, 11:15*am, "ats@jbex" <al...@allenjones.NOSPAM.co.PLEASE.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:

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
Sep 23 '08 #10
ats
On Fri, 19 Sep 2008 23:56:32 +0200, Gillard wrote:
have a look there
http://en.wikipedia.org/wiki/Credit_card_numbers

http://en.wikipedia.org/wiki/ISO_7812

http://en.wikipedia.org/wiki/Luhn_algorithm
"ats@jbex" <al***@allenjones.NOSPAM.co.PLEASE.ukwrote in message
news:9q****************************@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
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
Sep 23 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nols | last post by:
Hi, i need some help (this wan't work) double outDoubleOrgJed; string orgJed = "1.0000000E+00" Double.TryParse(orgJed, System.Globalization.NumberStyles.Float , null, out outDoubleOrgJed)
5
by: Greg Wilkerson | last post by:
Ok, Someone tell me what I'm doing wrong. The statement below is returning 527.0 in v, instead of the expected 215. Am I missing something? double v; if (Double.TryParse("0d7",...
1
by: Joachim | last post by:
When I run double.TryParse("12.01234567890123456789", out value) I only get 12.0123456789012 as result. How can I get double.TryParse to translate more than 13 decimals (if possible)?
5
by: MC | last post by:
Let's say I want to validate something with TryParse but I don't need to convert it. In C#, it seems I must provide that out parameter regardless. In VB, I can pass Nothing. I'd like to be able...
1
by: John A Grandy | last post by:
Primitives like Int32 provide a Parse() method , and TryParse() method -- which is very useful. Enum provides a Parse() method, but not a TryParse() method. Other than wrapping the...
5
by: Steffan A. Cline | last post by:
When using this as indicated and trying to set it to accept multiple formats, it bombs out with the error: Overload resolution failed because no accessible 'TryParse' accepts this number of...
1
by: dehranph | last post by:
I have this code that always return zero whenever i passed 1,000,00 in a da-DK culture or en-US culture. It works with amount less that 1000 like 99,99. but always returns 0 when greater than or...
3
by: nautonnier | last post by:
Hello All, I'm validating a textbox to make sure it contains only a whole number so I'm using Int32.TryParse. It works fine when I test it on a local winform app. However, when I transfer the...
2
by: steven | last post by:
Hi Anybody know why there's no TryParse method for a string type? I can do the following when trying to convert an object to int: object oTest = 1; int iValue; int.TryParse(oTest, iValue); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.