如何编制一个IP输入框?

侃侃2016 2004-09-06 10:50:41
编制写一个IP的输入框,像windows中设置本地地址那种?0.0.0.0
...全文
116 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ehom 2004-09-12
  • 打赏
  • 举报
回复
google
侃侃2016 2004-09-12
  • 打赏
  • 举报
回复
能否提供一个IPEDIT的控件
ehom 2004-09-06
  • 打赏
  • 举报
回复
这个MS提供了,IPEdit也就是封装了一下
ly_liuyang 2004-09-06
  • 打赏
  • 举报
回复
网上有很多IPEdit组件的
下载来用了:)
SuanAddMiao 2004-09-06
  • 打赏
  • 举报
回复
用一个判断函数就行了。
function TCSForm.IsLegalIP(IP:string):boolean;
var
i, j, l: integer;
ips: array [1..4] of string;
begin
i:=1;
for l:=1 to 4 do ips[l]:='';
for j:=1 to length(ip) do
if ip[j]<>'.' then
begin
if (ip[j]<'0')or(ip[j]>'9') then
begin
//showmessage(ip[j]);
Result:=false;
exit;
end;
ips[i]:=ips[i]+ip[j]
end
else inc(i);
if (i<>4)
or((strtoint(ips[1])>255)or(strtoint(ips[1])<0)) //originally is <1
or((strtoint(ips[2])>255)or(strtoint(ips[2])<0))
or((strtoint(ips[3])>255)or(strtoint(ips[3])<0))
or((strtoint(ips[4])>255)or(strtoint(ips[4])<0)) then
Result:= false
else
Result:= true;
end;

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧