I have a bit of a problem. I want this code to ping a remote host and monitor for a downage, but I can't get the text to display in the boxes, so I have no idea whether it's pinging or not. All I know is it just freezes when I run it. Seems like the correct implementation of a loop to me, so I'm not sure what's wrong. Maybe my Ifs/End Ifs are in the wrong places, but I've swapped them around a couple times.
The code is as follows:
Imports System.Net.NetworkInformation Public Class Form1 Dim Fails As Integer = 0 Dim Downage As Boolean = False Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Do Until Downage = True Dim Pingas As Integer = 0 Dim Server As String = "127.0.0.1" Dim TimeOut As Integer = 200 Dim PingServer As Ping = New Ping() Dim Reply As PingReply = PingServer.Send(Server) If Reply.Status = IPStatus.Success Then Pingas += 1 End If TextBox1.Text = Pingas If Reply.Status = IPStatus.TimedOut Then Fails += 1 End If If Fails >= 15 Then Downage = True End If TextBox1.Text = Pingas TextBox2.Text = Fails Loop End Sub End Class
I appreciate your input! Thanks!