Private Function GetIP() As String ' Dim ms As IO.Stream = Nothing ' Try Dim client As New Net.WebClient ms = client.OpenRead("http://www.elydian.fr") Dim sr As New IO.StreamReader(ms) Dim htmlPage As String = sr.ReadToEnd Dim re As New System.Text.RegularExpressions.Regex("([0-9]{1,3}\.){3}[0-9]{1,3}") Dim ip As String = re.Match(htmlPage).Value Return ip Catch ex As Exception MessageBox.Show("Erreur durant la récupération de l'adresse l'IP du serveur") Return Nothing Finally If ms IsNot Nothing Then ms.Close() ms.Dispose() End If End Try ' End Function
80.80.80.80
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim html As String = " 80.80.80.80 " Dim re As New System.Text.RegularExpressions.Regex("([0-9]{1,3}\.){3}[0-9]{1,3}") Dim ip As String = re.Match(html).Value MessageBox.Show(ip)
Imports System.Net Public NotInheritable Class form8 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If txturl.Text = "" Then MessageBox.Show("Veuillez entrer un site web", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) ElseIf txturl.Text = "www." Then MessageBox.Show("Veuillez entrer un site web valide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) ElseIf txturl.Text.StartsWith("www.") = True Then Dim hostname As IPHostEntry = Dns.GetHostEntry(txturl.Text) Dim ip As IPAddress() = hostname.AddressList ComboBox2.Text = ip(0).ToString() Else Dim hostname As IPHostEntry = Dns.GetHostEntry("www." & txturl.Text) Dim ip As IPAddress() = hostname.AddressList ComboBox2.Text = ip(0).ToString() End If End Sub Private Sub txturl_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) If e.KeyCode = Keys.Enter Then If txturl.Text = "" Then MessageBox.Show("Veuillez entrer un site web", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) ElseIf txturl.Text = "www." Then MessageBox.Show("Veuillez entrer un site web valide", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) ElseIf txturl.Text.Contains("www.") = True Then Dim hostname As IPHostEntry = Dns.GetHostEntry(txturl.Text) Dim ip As IPAddress() = hostname.AddressList ComboBox2.Text = ip(0).ToString() Else Dim hostname As IPHostEntry = Dns.GetHostEntry("www." & txturl.Text) Dim ip As IPAddress() = hostname.AddressList ComboBox2.Text = ip(0).ToString() End If End If End Sub End Class
Dim ip As IPAddress() = hostname.AddressList For Each Item As String In ip ComboBox2.Item.Add(Item) Next ComboBox2.Text = ip(0).ToString()
Mettre une textbox que tu renomme "combobox2"