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.
You may also like: Facial Recognition System in C#