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."
Umm VB Code: Private Sub ValidateIP(ByVal IP As Object) Try Dim IpObject As Object = Net.IPAddress.Parse(IP) If IpObject.ToString = Net.IPAddress.Parse(IP).ToString Then MessageBox.Show(IpObject.ToString + " Valid IP Address") End If Catch ex As Exception MessageBox.Show("Invalid IP Address") End Try End Sub Usage VB Code: 1-valid IP ValidateIP("20.102.255.5") 2-Invalid ValidateIP("20.102.255.256")
Private Sub ValidateIP(ByVal IP As Object) Try Dim IpObject As Object = Net.IPAddress.Parse(IP) If IpObject.ToString = Net.IPAddress.Parse(IP).ToString Then MessageBox.Show(IpObject.ToString + " Valid IP Address") End If Catch ex As Exception MessageBox.Show("Invalid IP Address") End Try End Sub
1-valid IP ValidateIP("20.102.255.5") 2-Invalid ValidateIP("20.102.255.256")
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
Forum Rules