L
lucarl
Unregistered / Unconfirmed
GUEST, unregistred user!
各位,能帮忙解决个小问题吗?
我换算的IP值为12位的,这个太大了,如何比较呢?
通过以上的进行换算 ,比方:192.168.0.1 ---- 192168000001(十二位)
我想传二个IP值,比大小 但是没办法老报出
[red]'192168000001 is not a valid integer values'[/red]
这是我的源代码
procedure TForm1.Button1Click(Sender: TObject);
var
HostByteOrder:longint;
begin
HostByteOrder := inet_addr(PChar(Form1.IPEdit1.IPString));
edit1.Text := Format('%.3d%.3d%.3d%.3d', [HostByteOrder and $FF,
(HostByteOrder shr 8) and $FF,
(HostByteOrder shr 16) and $FF,
(HostByteOrder shr 24) and $FF]);
HostByteOrder := inet_addr(PChar(Form1.IPEdit2.IPString));
edit2.Text := Format('%.3d%.3d%.3d%.3d', [HostByteOrder and $FF,
(HostByteOrder shr 8) and $FF,
(HostByteOrder shr 16) and $FF,
(HostByteOrder shr 24) and $FF]);
if StrToInt(Edit1.Text) < StrToInt(edit2.Text) then
ShowMessage('Edit1 Small')
else
ShowMessage('Edit1 Big');
end
我换算的IP值为12位的,这个太大了,如何比较呢?
通过以上的进行换算 ,比方:192.168.0.1 ---- 192168000001(十二位)
我想传二个IP值,比大小 但是没办法老报出
[red]'192168000001 is not a valid integer values'[/red]
这是我的源代码
procedure TForm1.Button1Click(Sender: TObject);
var
HostByteOrder:longint;
begin
HostByteOrder := inet_addr(PChar(Form1.IPEdit1.IPString));
edit1.Text := Format('%.3d%.3d%.3d%.3d', [HostByteOrder and $FF,
(HostByteOrder shr 8) and $FF,
(HostByteOrder shr 16) and $FF,
(HostByteOrder shr 24) and $FF]);
HostByteOrder := inet_addr(PChar(Form1.IPEdit2.IPString));
edit2.Text := Format('%.3d%.3d%.3d%.3d', [HostByteOrder and $FF,
(HostByteOrder shr 8) and $FF,
(HostByteOrder shr 16) and $FF,
(HostByteOrder shr 24) and $FF]);
if StrToInt(Edit1.Text) < StrToInt(edit2.Text) then
ShowMessage('Edit1 Small')
else
ShowMessage('Edit1 Big');
end