现有字符串
str:='56.27.25.63|||57.28.63.55|||21.75.122.533|||'
希望随机生成一个ip地址,但不能包含str中已有的地址。求这样的代码
str:='56.27.25.63|||57.28.63.55|||21.75.122.533|||'
希望随机生成一个ip地址,但不能包含str中已有的地址。求这样的代码
解决方案 »
- Delphi 6调用C++写的DLL,全局变量当参数出错
- 关于Installshield的简单问题!急~!!!!!
- 在主窗体实现子窗体:在主窗体的panel上展开,并可自由拖动???
- (北京)delphi 6 开发人员指南,便宜卖了,谁要
- 小问题数据库问题!谢谢帮忙(BDE)TDatabase TTable
- 大哥,大姐,帮帮忙呀!关于执行一个dos下的批处理文件
- 消息截获
- SOS,如果500分能够救我的话,我情愿再拿出500分,让大侠喝点茶,,,,
- delphi5过期问题
- 用ClientDataSet开发单层文件型数据库应用程序时如何使用SQL语句?
- 如何把这个if语句转换成case语句?
- 请问delphi7如何实现发送邮件
var
ss:TStrings;
begin
ss:=TStringList.Create;
ss.clear;
extractstrings(['|||'],[],pchar(str),ss)
end;
得出字符串中已有IP地址
然后再随机生成IP地址IP
i:=ss.index(ip);
判断i是否等于-1。如果等于-1就说明没在str中
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;
var ss:string;Randomize;
ss:='56.27.25.63|||57.28.63.55|||21.75.122.533|||';while ss.indexOf(strip)>-1 do ////////////////////这里报错
begin
strip=Format('10.%d.%d.%d',
[Random(255), Random(255), Random(254) + 1])
end请问该怎么写?