比如在两个输入框中输入:
135.35.1.1
135.36.1.2则输出:
135.35.1.1
135.35.1.2
135.35.1.3
……
135.35.1.254
135.35.1.255
135.36.1.0
135.36.1.1
135.36.1.2另外,如果我用一个数组把所有合法可能的IP地址放在这个数组里,能装得下吗?会不会有什么问题?
135.35.1.1
135.36.1.2则输出:
135.35.1.1
135.35.1.2
135.35.1.3
……
135.35.1.254
135.35.1.255
135.36.1.0
135.36.1.1
135.36.1.2另外,如果我用一个数组把所有合法可能的IP地址放在这个数组里,能装得下吗?会不会有什么问题?
解决方案 »
- win7下运行delphi7
- 有个3MB的数组,int64的. 放数据库/txt还是直接用数组呢?
- 关于用ACCESS+DELPHI做为的登录代码,帮帮忙看下,密码修改后,出现密码出错,无法登录
- dbgrid如何实现右键点cell后弹出PopupMenu
- 为什么我运行corba的demos\idl2pas的accountserver出现无法定位程序输入点?
- 如何用DELPHI或其它面向对象的方法实现像SAP一样的三层结构
- 如何制作一个IP地址输入框啊,并且能检测输入的正确性?
- 请教关于Windows程序设计的几个基本问题!(急)
- 界面问题
- 不规则按钮如何实现:如圆形(简便方法?)
- 有淄博的朋友吗?会DELPHI的?
- 谁有Delphi的心跳程序
for i:=a to b do
输出:把i转为ip
对比后,各段若有不同值,将其记录下来,接下来就是根据记录的数据,输出IP地址了~~
uses StrUtils;function IPToDWORD(sIP: String): DWord;
var
a: array [0..3] of Byte;
i, j, k: Integer;
begin
i := 0;
for k := 3 downto 1 do
begin
a[k] := 0;
j := PosEx('.', sIP, i + 1);
if j > i then
begin
a[k] := StrToIntDef(Copy(sIP, i + 1, j - i - 1), 0);
i := j;
end;
end;
a[0] := StrToIntDef(Copy(sIP, i + 1, Length(sIP) - i), 0);
Move(a[0], Result, 4);
end;function DWORDToIP(iIP: DWORD): String;
var
a: array [0..3] of Byte;
i: Integer;
begin
Move(iIP, a[0], 4);
Result := IntToStr(a[3]);
for i := 2 downto 0 do
Result := Result + '.' + IntToStr(a[i]);
end;procedure TForm1.FormCreate(Sender: TObject);
var
i : DWORD;
begin
for i := IPToDWORD('135.35.1.1') to IPToDWORD('135.35.2.1') do
Memo1.Lines.Add (DWORDToIP(i));
end;