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 ipdusite.Text = ip(0).ToString() Else Dim hostname As IPHostEntry = Dns.GetHostEntry("www." & txturl.Text) Dim ip As IPAddress() = hostname.AddressList ipdusite.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 ipdusite.Text = ip(0).ToString() Else Dim hostname As IPHostEntry = Dns.GetHostEntry("www." & txturl.Text) Dim ip As IPAddress() = hostname.AddressList ipdusite.Text = ip(0).ToString() End If End If End Sub End Class