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('否');

  

   演示结果 

   

原文地址:https://www.cnblogs.com/huasoft/p/13667159.html