How to: Check Connection Status in Visual Basic

The My.Computer.Network.IsAvailable Property can be used to determine whether the computer has a working network or Internet connection.


  The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help, depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

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 = True 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 How to: Insert Snippets Into Your Code (Visual Basic).

See Also


How to: Determine if a Remote Computer is Available in Visual Basic


My.Computer.Network Object

My.Computer.Network.IsAvailable Property