给你一个方法,你把它建在资源集里,然后就可以在功能里调用了!
static Function TXTGGZYJ.IsNumber(UserStr:String):Boolean;
var
I,J:Integer;
myText:String;
Begin
J:=0;
Result:=False;
For I:=0 to UserStr.Length-1 do
Begin
myText:=UserStr.Substring (I,1);
if ((myText='0') or (myText='1') or (myText='2') or (myText='3') or
(myText='4') or (myText='5') or (myText='6') or (myText='7') or
(myText='8') or (myText='9') or (myText='.')) then
Begin
Result:=True;
if myText='.' then J:=J+1;
End
Else
Begin
Result:=False;
End;
End;
////如果字符串中起来两个.
if J>1 then Result:=False;
////如果字符串中第一个为.或者最后一个为.
if ((UserStr.Substring (0,1)='.') or (UserStr.Substring (Userstr.Length -1,1)='.')) then
Begin
Result:=False;
End
End; |