Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 2007
-
3 mars 2006 à 21:47
Lucyberad
Messages postés414Date d'inscriptionmercredi 16 juin 2004StatutMembreDernière intervention26 juillet 2007
-
3 mars 2006 à 23:13
Bonjour a tous,
voila j'essai de faire un ping vers plusieurs site pour que le programme detecte si y'as le net.
voici le code utilisé:
Dim WithEvents pingclient As New Net.NetworkInformation.Ping
Private Sub Ajout_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
pingclient.SendAsync("www.google.fr", Nothing)
End Sub
Private Sub pingClient_PingCompleted(ByVal sender As Object, ByVal e As Net.NetworkInformation.PingCompletedEventArgs) Handles pingClient.PingCompleted
Select Case e.Reply.Status
Case Net.NetworkInformation.IPStatus.Success
MsgBox("OK")
Case Net.NetworkInformation.IPStatus.HardwareError
MsgBox("Pas bon !")
End Select
End Sub
mais voila, le programme fonctionne quand je laisse google.fr
par contre j'ai voulu voir avec un site qui nexiste pas (qu'il n'arrive aps a pinger donc) ca ne marche pas, j'ai pris www.lucyberad.fr qui n'existe pas !
il me renvoie cet erreur: TargetInvocationException
mettant ceci comme commentaire: Exception has been thrown by the target of an invocation.
[...]
Try
Select Case e.Reply.Status
Case Net.NetworkInformation.IPStatus.Success
MsgBox("OK")
Case Net.NetworkInformation.IPStatus.HardwareError
MsgBox("Pas bon !")
End Select
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("Heu, ca marche pas là ?" & vbCrLf & "Enfin, met ton message perso ou n'en met pas")
End Try
[...]
Kenji
<hr size="2" width="100%">
Merci de cliquer sur "Réponse acceptée" si une réponse vous convient.