View Single Post
Old 12-11-2017, 05:05 AM
Zander Zander is offline
Registered User
Join Date: Oct 2016
Posts: 11
Late Reply...

Hi Jake,

Apologies for not replying last year, very rude of me!

Thank you very much for your help though, I've just started making some edits to my script and found that the issue I had was that I was referencing the wrong string in my script! I was defining the clipboard text as a string, removing all of the unneeded characters from it but then when I was running the checks against it I was using the original clipboard variable and not the string!

If you compare to my above post(s), I had "crt.Clipboard.Text" where "strAddress" now is!

    Set re = New RegExp
        ' Set up a pattern that starts at the beginning ("^"), and looks for a
        ' digit that's between 1 and 3 characters long ("\d{1,3}"), followed by
        ' a dot character ("\.") (repeated again 3 times, but the last one
        ' doesn't have a trailing dot character), followed immediately by the
        ' end of the input ("$"):
        re.Pattern = "^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$"

    Set matches = re.Execute(strAddress)
    If matches.Count < 1 Then
        MsgBox "Invalid IPv4 address copied!"
        Exit Sub
        'Now check to see if each octet is within a valid range
        bValid = True
        For Each nOctet In matches(0).Submatches
        If nOctet < 0 Or nOctet > 255 Then
            MsgBox "You're trying to use an invalid IP address!"
            Exit Sub
            bValid = False
        End If
    End If
Reply With Quote