Results 1 to 3 of 3

Thread: How do you

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108

    How do you

    validate an IP Address? i'm sure .NET has something like that.
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Umm

    VB Code:
    1. Private Sub ValidateIP(ByVal IP As Object)
    2.  
    3.         Try
    4.             Dim IpObject As Object = Net.IPAddress.Parse(IP)
    5.             If IpObject.ToString = Net.IPAddress.Parse(IP).ToString Then
    6.                 MessageBox.Show(IpObject.ToString + "  Valid IP Address")
    7.             End If
    8.  
    9.         Catch ex As Exception
    10.             MessageBox.Show("Invalid IP Address")
    11.         End Try
    12.     End Sub



    Usage

    VB Code:
    1. 1-valid IP
    2.  ValidateIP("20.102.255.5")
    3.  
    4. 2-Invalid
    5.  ValidateIP("20.102.255.256")

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Just to add a note:
    In case you need to validate IPv6 you need to enable its support both in machine.config and in your OS.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width