Delph i判断IP地址是否正确


本文整理自网络,侵删。

 function IsValidIP(strIP: string): Boolean;
var
  i, PartCount {用多少段,以点号分开}: Integer;
  Part: string;
begin
  PartCount := 0;
  while strIP <> '' do
  begin
    i := Pos('.', strIP);
    if i = 0 then
    begin
      Part := strIP;
      strIP := '';
    end
    else
    begin
      Part := Copy(strIP, 1, i - 1);
      Delete(strIP, 1, i);
    end;
    //IP分段必须是[0,255]的整数
    if not TryStrToInt(Part, i) or (i < 0) or (i > 255) then
    begin
      Result := False;
      Exit;
    end;
    Inc(PartCount);
  end;
  Result := PartCount = 4; //必须要有4段
end;

相关阅读 >>

Delphi jpg文件合并器代码

Delphi将excel导入access

Delphi:窗体的扩展样式gwl_exstyle用于setwindowlong

Delphi 复制文件到全盘

Delphi xe 获取 android application version 版本

Delphi monthcalendar1 获取选中日期

纯真ip数据库解析Delphi d10.1下正常使用

Delphi 命令行 打开读写txt文件

Delphi xe6 firemonkey移动应用程序的twebbrowser html页面上运行javascript

Delphi 播放背景音乐

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...