注册 登录
编程论坛 Delphi论坛

[求助]isNumeric

baoxuelan 发布于 2006-08-19 22:58, 958 次点击
unction TfrmConsumptionInfo.isInteger(s: string): boolean; //自定义函数
var
i:integer;
begin
i:=1;
if length(s)=0 then
begin
result:=false;
exit;
end;
while i<=length(s) do
begin
if (isNumeric(s[i])=false) then
begin
result:=false;
exit;
end;
i:=i+1;
end;
result:=true;
end;
为什么到这里就过不去了,是不是那里需要引用下!!! if (isNumeric(s[i])=false) then里的isNumeric;
4 回复
#2
xu20002006-08-20 22:37
你有声明数组吗? 
#3
baoxuelan2006-08-20 23:49
我没有任何声明,可是书上的例子可以通过运行,不知道那里的得错!!!我找过看看是不是那里声明了全局变量可是没有!!!

isNumeric这个函数在delphi7.0中不能用!!
#4
ysp_19842006-08-25 10:24

自己写一个
function isnumeric(s: shortstring): boolean;
var
i:byte;
begin
if length(s)=0 then exit;
for i:=1 to length(s) do
begin
if not (s[i] in ['0'..'9']) then
begin
result:=false;
break;
end
else
result:=true;
end;


end;

#5
volte2006-08-25 13:45
function IsNumeric(s : ShortString): Boolean;
var
i : Integer;
begin
Result := False;
if Length(S) then
Exit;
for i := 1 to Length(S) do
begin
if (S[i] in ['0'..'9'] then
Continue
else
Break;
end;
if i > Length[S] then
Result := True;
end;

[此贴子已经被作者于2006-8-25 13:46:14编辑过]

1