1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
If IcConnectionAvailable(Site1) = true) Then
msgbox("Supper , ça marche ")
Else
MsgBox("Le site n'est pas accessible")
End if
If connectionAvailable(Site2) = true Then
MsgBox("Super , ça marche")
Else
MsgBox(" Le site n'est pas accessible")
Public Function IsConnectionAvailable(ByVal Site1 As String, ByVal Site2 As String) As Boolean
Site1 = "http://Site1.com"
Site2 = "http://google.fr"
Dim objUrl As New System.Uri(" ??? " ) ' Je ne vois pas quoi mettre
Dim objWebReq As System.Net.WebRequest
objWebReq = System.Net.WebRequest.Create(objUrl)
Dim objresp As System.Net.WebResponse
Try
objresp = objWebReq.GetResponse
objresp.Close()
objresp = Nothing
Return True
Catch ex As Exception
objresp = Nothing
objWebReq = Nothing
Return False
End Try
End Function |
Partager