How to check my PC or Laptop is connected with internet or Not. VB. Net code for beginners

Here I am going to show the VB.Net code for checking whether the computer is connected with internet or not. such code is has its importance when you are designing a windows for sending email so before sending email, this code will check whether your for inter net connection.for checking online connection , I have made a function called Isonline checking www.Google.com . here I can use any other domain but I have used Google as it is very rare chance that google is down or not working. if Google is down then this code will not work. After codding the function IsOnline,

 Private Function IsOnline() As Boolean ‘for checking net connection)
            Dim inet As Net.IPHostEntry = Net.Dns.GetHostEntry("www.google.com")
            Return True
        Catch ex As Net.Sockets.SocketException
            Return False
        End Try
    End Function

 I have called that function  at the click event of email send button

        If IsOnline() = False Then “ to check whether your connected with internet or not
            MsgBox("Check Your Internet Connection")
            MsgBox("Message has been Sent successfully.")

        End If
            End Sub
    This code is working great.