How to: Check Connection Status in Visual Basic


The IsAvailable property can be used to determine whether the computer has a working network or Internet connection.


Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalizing the Visual Studio IDE.

To check whether a computer has a working connection

  • Determine whether the IsAvailable property is True or False. The following code checks the property's status and reports it:

    If My.Computer.Network.IsAvailable Then
        MsgBox("Computer is connected.")
        MsgBox("Computer is not connected.")
    End If

    This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Connectivity and Networking. For more information, see Code Snippets.