Tuesday, 15 November 2011
Home »
Tips and Trick Delphi
» Check the input character is numeric or not by Delphi
Check the input character is numeric or not by Delphi
To Share | Tuesday, 15 November 2011
Error handler using the try - except. Function declaration:
isnumber function (n: String): Boolean;
begin
try
StrToInt (n);
Result: = True;
except
Result: = False;
end;
end;
If the input is numeric, then the result is True and False if it is not worth the result.
implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
if isnumber (Edit1.Text) then ShowMessage ('Input is numeric! ")
else ShowMessage ('Input not a number!');
end;
As proof, run through the debugger without Delphi (compile and run the exe file that has been finished).
No comments:
Post a Comment