IP格式判断函数

大家可以把代码中的ip地址192.168.1.1改成其它错误格式的ip,看代码是否能正确报出错误!

代码如下:

PDGS("192.168.1.1")

Func PDGS($value)
        $IP=StringSplit($value,".")
        If $IP[0]=4 Then          
                For $i=1 to 4
                        $csz=$IP[$i]
                        $bdz="^\d{1,3}contentquot;
                        $aReturn = StringRegExp($csz,$bdz, 3)
                        If Not IsArray($aReturn) Then
                                MsgBox(64,"警告",$value & " 中的 " & $csz & " 不是有效IP地址范围!")
                                Return False                                                        
                        Else
                                If $csz > 255 Then                                        
                                        MsgBox(64,"警告",$value & " 中的 " & $csz & " IP数值超出!")
                                        Return False                                                
                                EndIf
                        EndIf ;====>Not IsArray
                Next
                Return True
        Else
                MsgBox(64,"警告",$value & " IP地址格式错误!")        
                Return False
        EndIf
EndFunc
申明:本站资源大部分来自网络,如果无意侵犯了你的权利,请及时通知我们 AutoIt@FoxMail.Com,我们将尽快处理
Copyright © 2008-2009 随便复制 共享精神 人人有责 All Right Reserved
粤ICP备08009024号