(* //
标题:检查数字字符串
说明:使用于运用程序检查用户数字输入
设计:Zswang
日期:2002-01-24
支持:wjhu111@21cn.com
// *)
/// ////Begin Source
function IsNumber(mStr: string): Boolean; { 返回字符串是否是正确的数字表达 }
var
I: Real;
E: Integer;
begin
Val(mStr, I, E);
Result := E = 0;
E := Trunc(I);
end; { IsNumber }
function IsInteger(mStr: string): Boolean; { 返回字符串是否是正确的整数表达 }
var
I: Integer;
E: Integer;
begin
Val(mStr, I, E);
Result := E = 0;
E := Trunc(I);
end; { IsInteger }
/// ////End Source
/// ////Begin Demo
procedure TForm1.Button1Click(Sender: TObject);
begin
CheckBox1.Checked := IsNumber(Edit1.Text);
CheckBox2.Checked := IsInteger(Edit1.Text);
end;
/// ////End Demo