Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Dim ip = "www.google.com" Dim timeout = 1000 Dim sw = New Stopwatch() Try Dim ping As Long = -1 sw.Start() If My.Computer.Network.Ping(ip, timeout) Then sw.Stop() ping = sw.ElapsedMilliseconds End If If ping < 0 Then Label2.Text = "Timed Out" Label2.BackColor = Color.Brown Label2.ForeColor = Color.White ElseIf ping < 200 Then Label2.Text = "Good Connection" Label2.BackColor = Color.Green Else Label2.Text = "Bad Connection" Label2.BackColor = Color.Red End If Catch ex As Exception Label2.Text = ex.Message Label2.BackColor = Color.Red Console.WriteLine(ex.ToString()) End Try End Sub End Class
<pre lang="vb"><pre lang="vb"><pre lang="vb">
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)