473,320 Members | 2,162 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,320 software developers and data experts.

validate textbox

Hallo,
I am begginer in C#. I would like to know how to validate data in
TextBox. So exactly I have to check if the value is a correct double
value. Can you give me some advice?
Maybe a link? Should I use a regular expression? or is there a simple
method?

Regards,
Daniel

Jan 3 '07 #1
5 2384
double value;
if(double.TryParse(textbox1.Text, out value)) {
// is a legal double, with the value now in "value"
}

Marc
Jan 3 '07 #2
dear Marc,
Thanks for help but it does not work under C# for Pocket PC ;-(

It works for normal windows Applications ;-)

Maybe you know how to it on pocket pc ??

Please help,
Regards,
Daniel

Marc Gravell napisal(a):
double value;
if(double.TryParse(textbox1.Text, out value)) {
// is a legal double, with the value now in "value"
}

Marc
Jan 3 '07 #3
Something like:

try {
double value = double.Parse(textbox1.Text);
} catch { // specifically FormatException and OverflowException
// illegal, do something funky
}

?

Marc
Jan 3 '07 #4
Additionally; just to avoid replies that don't help you, it is usually
worth mentioning (like you did with your later "hide application"
question) details like "Pocket PC", "1.1 only", "no 3rd party
components" etc... it doesn't cause any real problems, but just takes
longer to get to an appropriate answer ;-p

Marc
Jan 3 '07 #5
Daniel,
It seems you are developing apps for the PPC , if this is true you will find
more targeted answers in the CF NG
--
Ignacio Machin
machin AT laceupsolutions com

"Daniel" <Da****************@gmail.comwrote in message
news:11**********************@n51g2000cwc.googlegr oups.com...
dear Marc,
Thanks for help but it does not work under C# for Pocket PC ;-(

It works for normal windows Applications ;-)

Maybe you know how to it on pocket pc ??

Please help,
Regards,
Daniel

Marc Gravell napisal(a):
>double value;
if(double.TryParse(textbox1.Text, out value)) {
// is a legal double, with the value now in "value"
}

Marc

Jan 3 '07 #6

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

Similar topics

3
by: rodger | last post by:
How do i validate text box entry, in VB. net In the event that user does not make a text entry, simply pop-up a warning, thanks rodger
5
by: Jeff Evans | last post by:
I have a custom composite control which has a validator for a textbox. The validator and textbox are declared in the class and created in the CreateChildControls() method Here is the code for the...
11
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the...
2
by: Peter | last post by:
I need to validate 4 fields on ASP.NET web page Starting Date __/__/____ Starting Time __:__ Ending Date __/__/____ Ending Time __:__ Staring Date + StartingTime...
7
by: Rich | last post by:
Hello, I have 10 textboxes on a form. I would like to validate text-data entry on each textbox. I was looking for a Form_Current event or Form_Change event but did not recognize any such...
9
by: B-Dog | last post by:
I have a form that has about 10 text boxes on it, they all have to be filled out before submitting is there a quick way to make sure that none are null or do I have to call out each textbox? Say...
11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
3
by: Jeff Jarrell | last post by:
I have one textbox on a form. Nothing else. The validate event doesn't fire. Drop another textbox on the form and the validate event fires. Set tabstop = false on the 2nd text box and the...
1
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.