Share via


My.Computer.Network.IsAvailable Property 

Indicates whether a computer is connected to a network.

' Usage
Dim value As Boolean = My.Computer.Network.IsAvailable
' Declaration
Public ReadOnly Property IsAvailable As Boolean

Return Value

Boolean.

Remarks

IsAvailable always returns False when called from a Click Once application or if the user does not have NetworkInformationPermission.

Tasks

The following table lists examples of tasks involving the My.Computer.Network.IsAvailable property.

To See

Check whether a computer is connected to a network

How to: Check Connection Status in Visual Basic

Example

This example checks the property's status and reports it.

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

Requirements

Namespace: Microsoft.VisualBasic.Devices

Class: Network

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

Permissions

The following permissions may be necessary:

Permission Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

WebPermission

Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

See Also

Tasks

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

Reference

My.Computer.Network Object
Microsoft.VisualBasic.Devices.Network.IsAvailable