频道分类

delphi 判断字符串是否包含数字

作者:admin 来源: 日期:2020/2/29 0:01:57 人气: 标签:

 
function checkstr1(const str: string): Boolean;
var
j:integer;
begin
Result :=false;
for J:=1 to Length(str) do
begin
if (str[J] in ['0'..'9']) then
begin
Result :=true;
break;
end;
end;
end;

procedure TForm16.Button1Click(Sender: TObject);
begin
if checkstr1(edit1.text) then
begin
  caption:='t';
  end
  else
  begin
   caption:='f';
  end;
end;