For Newbie

Tuesday, 15 November 2011

check the numbers by delphi




Validation function to check whether the pulled-numeric characters or not.

This is an alternative to the previous ways, namely: Check Input Form of Numbers.
Function declaration:
ceknumber function (const INP: string): Boolean;
var
   v: PChar;
begin
   Result: = False;
   v: = PChar (INP);
   while v ^ <> # 0 do
   begin
     if not (v ^ in ['0 '.. '9']) then Exit;
     Inc. (v);
   end;
   Result: = True;
end;

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
   if Trim (Edit1.Text) =''then Exit;
   CheckBox1.Checked: = Ceknumber(Edit1.Text);
end;

Share on Facebook
Share on Twitter
Share on Google+

Related : check the numbers by delphi