Kod:
Public Function BaglantiKontrol() As Boolean
Dim yol As New System.Uri("http://www.microsoft.com/")
'Bağlantı varolup olmadığını kontrol etmek için
'girdiğimiz internet adresinin bir önemi yok. herhangi bir adreste
'olabilir.
Dim istek As System.Net.WebRequest
istek = System.Net.WebRequest.Create(yol)
Dim Cevap As System.Net.WebResponse
Try
Cevap = istek.GetResponse
Cevap.Close()
istek = Nothing
Return True
Catch ex As Exception
istek = Nothing
Return False
End Try
End Function
Istediğiniz Yerde Kullanabilrsiniz.
Kod:
If BaglantiKontrol() = True Then
Label4.Text = "Internet Bağlantınız Mevcut"
Label4.ForeColor = Color.DarkGreen
Else
Label4.Text = "Internet Bağlantınız Mevcut Değil"
Label4.ForeColor = Color.Red
End If
SON OLARAK TEŞEKKÜR BUTONUNA BASMAYI UNUTMAYALIM.