Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

No text output on ping loop

$
0
0
Hi, guys. I was wondering if you could once again point out my silly mistakes for me! I'll eventually learn how to do this the right way, without asking questions.

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!

Originally (And incorrectly) posted in VB6 Forums. I am using VStudio 2012 Professional.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>