16,748
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button1Click(Sender: TObject);
var
ip,s,s1,s2,s3,s4:string;
i,j:Integer;
b:Boolean;
begin
b:=False;
while b=False do
begin
Randomize;
ip:='';
for j:=1 to 12 do
begin
i:=Random(9);
s:=IntToStr(i);
if (j<>4) and (j<>7) and (j<>10) then
ip:=ip+s
else
ip:=ip+'.'+s;
end;
if Copy(ip,1,3)='000' then
b:=False
else
b:=True;
end;
s1:=Copy(ip,1,3);
s2:=Copy(ip,5,3);
s3:=Copy(ip,9,3);
s4:=Copy(ip,13,3);
ip:=IntToStr(StrToInt(s1))+'.'+IntToStr(StrToInt(s2))+'.'+IntToStr(StrToInt(s3))+'.'+
IntToStr(StrToInt(s4));
self.Label1.Caption:=ip;
end;