validate textbox

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

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
 
double value;
if(double.TryParse(textbox1.Text, out value)) {
// is a legal double, with the value now in "value"
}

Marc
 
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):
 
Something like:

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

?

Marc
 
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
 
Daniel,


It seems you are developing apps for the PPC , if this is true you will find
more targeted answers in the CF NG
 

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

Back
Top