--> check the numbers by delphi | Delphi Tips Trick

For Newbie

Tuesday 15 November 2011

check the numbers by delphi

| Tuesday 15 November 2011



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;

Related Posts

No comments: