Pinging Loop Error

Page 1 of 1

2 Replies - 480 Views - Last Post: 19 January 2013 - 09:29 PM Rate Topic: -----

#1 Absolute Zero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 21-June 11

Pinging Loop Error

Posted 19 January 2013 - 01:21 PM

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!

Is This A Good Question/Topic? 0
  • +

Replies To: Pinging Loop Error

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5677
  • View blog
  • Posts: 12,211
  • Joined: 02-June 10

Re: Pinging Loop Error

Posted 19 January 2013 - 02:41 PM

Please don't open multiple threads for the same question
http://www.dreaminco...t-on-ping-loop/
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9579
  • View blog
  • Posts: 36,298
  • Joined: 12-June 08

Re: Pinging Loop Error

Posted 19 January 2013 - 09:29 PM

Agreed. Closing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1