Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I verify that a text box contains only numbers in Delphi?

Might it is very simple question but I never touched delphi. I have a edit box and that can accept character. But on some special condition I have to verify the edit box character are only numbers.

How can we do that?

Note: user can enter any char but at the time of validation I have to verify above one.

like image 276
PawanS Avatar asked Jun 23 '11 13:06

PawanS


1 Answers

I don't know what event you intend to use to invoke validation, but the validation can be done like this:

if TryStrToInt(Edit1.Text, Value) then
  DoSomethingWithTheNumber(Value)
else
  HandleNotANumberError(Edit1.Text);
like image 160
David Heffernan Avatar answered Sep 29 '22 13:09

David Heffernan