Check Internet Connection Status in Visual Basic

check internet connection status in visual basic
How to check internet connection status in Visual Basic.

In Visual Basic, you can check the internet connection status using the System.Net.NetworkInformation namespace.

Here’s an example of how you can check if the internet is available in a Visual Basic application:

Imports System.Net.NetworkInformation
Public Class Form2
    Private Sub btnCheckInternt_Click(sender As Object, e As EventArgs) Handles btnCheckInternt.Click
        CheckConnection()
    End Sub

    Private Sub CheckConnection()
        If NetworkInterface.GetIsNetworkAvailable() Then
            MessageBox.Show("Internet Connection is available", "Check Internet Connection in VB.NET", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            MessageBox.Show("No Internet Connection available", "Check Internet Connection in VB.NET", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub
End Class

In this example, the NetworkInterface.GetIsNetworkAvailable() function indicates whether any network connection is available.

Returns True if a network is available and a message box will show that the internet connection is available, otherwise, false and a message box will show that there is no internet connection available.

Make sure to add a button (in this example, Button1) to your form that calls the CheckConnection method when clicked.

Download Source Code

You may also like: Facial Recognition System in C#

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping