Tuesday, 15 November 2011
Home »
Tips and Trick Delphi
» check the numbers by delphi
check the numbers by delphi
To Share | 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;
No comments:
Post a Comment