Connecting Tech Pros Worldwide Forums | Help | Site Map

validating TextBox text

Andrea
Guest
 
Posts: n/a
#1: Nov 20 '05
If anyone has a simple routine to validate that text
entered in a text box control contains only numbers (zip
code) or only alpha characters (name), can you please send
me? I'm new to this, and am not looking in the right
places to find answers.
Thanks!
Andrea

Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: validating TextBox text


* "Andrea" <andreadecker@fairisaac.com> scripsit:[color=blue]
> If anyone has a simple routine to validate that text
> entered in a text box control contains only numbers (zip
> code) or only alpha characters (name), can you please send
> me? I'm new to this, and am not looking in the right
> places to find answers.[/color]

You can use 'Double.TryParse' to check if the user entered a valid
number into the textbox. For more complex formats, you may want to use
a MaskEdit control:

FlexMaskEditBox - a masked edit control
<http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp>

Validation can be done with regular expressions too
('System.Text.RegularExpression.Regex').

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
EricJ
Guest
 
Posts: n/a
#3: Nov 20 '05

re: validating TextBox text


in addition there is also an isnumeric(yourstring) function

but a zip code dousnt have to be all numbers so watch out w that one

eric

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:bqj41f$1vu2c0$3@ID-208219.news.uni-berlin.de...[color=blue]
> * "Andrea" <andreadecker@fairisaac.com> scripsit:[color=green]
> > If anyone has a simple routine to validate that text
> > entered in a text box control contains only numbers (zip
> > code) or only alpha characters (name), can you please send
> > me? I'm new to this, and am not looking in the right
> > places to find answers.[/color]
>
> You can use 'Double.TryParse' to check if the user entered a valid
> number into the textbox. For more complex formats, you may want to use
> a MaskEdit control:
>
> FlexMaskEditBox - a masked edit control
> <http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp>
>
> Validation can be done with regular expressions too
> ('System.Text.RegularExpression.Regex').
>
> --
> Herfried K. Wagner [MVP]
> <http://www.mvps.org/dotnet>[/color]


Closed Thread


Similar Visual Basic .NET bytes