Jump to content
Sign in to follow this  

Compare Ip To Mask

Recommended Posts


This function accepts an IP address and a mask to compare it to and returns either a o if false or a 1 if true. For the mask you can replace octets with an asterisk as a wild card. The function accepts mutltiple wildcards.


CompareIP("","10.0.0.*") = True

CompareIP("","10.0.0.*") = True

CompareIP("","10.*") = True

CompareIP("","*.*.*.2") = False

Func CompareIP($IP, $Mask)
    Local $i

    $IP = StringSplit($IP, ".")
    $Mask = StringSplit($Mask, ".")

    For $i = 1 To ubound($mask) -1
        If $Mask[$i] <> "*" Then
            If int($IP[$i]) <> int($Mask[$i]) Then Return 0
    Return 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.