[Visual Basic] Check internet connection

Hi mọi người, với thủ thuật "GET IP ADRESSBAR" này thì đã có chia sẽ rất nhiều trên "INTERNET", nhưng hôm nay Hùng chia sẽ lại cho mọi người, sợ mọi người quên thủ thuật này :D

Thủ Thuật này giúp người dùng sữ dụng VB.Net kiểm tra xem có internet không.
Trong code này mình có sữ dụng 2 hàm (Boolean) để kiểm tra kết nối.
1,Check internet connection using Computer.Network.Ping("google.com")
2,Check internet connection Using stream = client.OpenRead("http://www.google.com")

FULL CODE
Public Class Form1
Function IsConnected() As Boolean
'Checks the internet connection
If My.Computer.Network.Ping("google.com").ToString = True Then
Label1.Text = ("Connected")
Label1.ForeColor = Color.Green
Else
Label1.Text = ("No Connection")
Label1.ForeColor = Color.Red
End If
Return True
End Function

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
'Check if there is an internet connection is available.
IsConnected()
End Sub

'Another function to check for internet connectivity
Public Function CheckForInternetConnection() As Boolean
Try
Using client = New WebClient()
Using stream = client.OpenRead("http://www.google.com")
Return True
End Using
End Using
Catch
Return False
End Try
End Function

Chúc các bạn thành công với thủ thuật này.