Delphi Tips Trick

For Newbie

Iklan Responsive Atas

LightBlog
Responsive Ads Here

Tuesday, 15 November 2011

Check the input character is numeric or not by Delphi



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: