你们的只是一个IP段的~
看我的~
edit2开始IP
edit3结束IP
listbox
procedure TForm1.Button1Click(Sender: TObject);
var
i11,i12,i13,i14,i21,i22,i23,i24,j,i:integer;
du1,du2,x: cardinal;
temp:string;
begin
try
temp:=edit2.Text;
j:=length(temp);
i:=pos('.',temp);
i11:=strtoint(copy(temp,1,i-1));
temp:=copy(temp,i+1,j-1);
j:=length(temp);
i:=pos('.',temp);
i12:=strtoint(copy(temp,1,i-1));
temp:=copy(temp,i+1,j-1);
j:=length(temp);
i:=pos('.',temp);
i13:=strtoint(copy(temp,1,i-1));
i14:=strtoint(copy(temp,i+1,j-1));
//---------------------------
temp:=edit3.Text;
j:=length(temp);
i:=pos('.',temp);
i21:=strtoint(copy(temp,1,i-1));
temp:=copy(temp,i+1,j-1);
j:=length(temp);
i:=pos('.',temp);
i22:=strtoint(copy(temp,1,i-1));
temp:=copy(temp,i+1,j-1);
j:=length(temp);
i:=pos('.',temp);
i23:=strtoint(copy(temp,1,i-1));
i24:=strtoint(copy(temp,i+1,j-1));
//-----------------------------
du1:=i11*256*256*256+i12*256*256+i13*256+i14;
du2:=i21*256*256*256+i22*256*256+i23*256+i24;
if du1>du2 then exit;
for x:=du1 to du2 do
begin
memo1.Lines.Add(inttostr(x div (256*256*256))+'.'+inttostr((x mod(256*256*256))div(256*256))+'.'+inttostr((x mod(256*256))div 256)+'.'+inttostr(x mod 256));
end;
except
showmessage('IP地址填写格式错误');
end;