Delphi判断一个字符串是否全是相同的数字

function TForm5.is_samestr(str: string): Boolean;
var
 total:integer;
 i:integer;
 a:string;
begin
   total :=Length(str);
   Result:=true;
   for i := 1 to total do
      begin
      a:=LeftStr(str,1);
      if a<>midStr(str,i,1) then
         begin
           Result:=false;
           Break;
         end;
      end;

end;

  调用示例

 

  if is_samestr('966666666') then
    ShowMessage('是')
    else
    ShowMessage('否');

  

   演示结果 

   

 

posted @ 2020-09-14 15:49  华华软件工作室  阅读(513)  评论(0编辑  收藏  举报