So i'm a newbie to
VB and i need some help doing something that is so simple i cant work it out.
I have a form that has a button, on clicking the button it pings a computer.
Code:
Private Sub btnPing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPing.Click
Dim Count As Integer
If My.Computer.Network.Ping("10.50.50.217") Then
lblDisplay.Text = "Server pinged successfully."
Count = 0
lblcount.Text = Count
Else
lblDisplay.Text = "Ping request timed out."
Count = Count + 1
lblcount.Text = Count
End If
End Sub
So i'm thinking people are already calling me stupid :). What i want to happen is when the button is clicked and the ping is ok it sets the counter (lblcount) to 0. Which works.
But if the ping fails i want the counter to count how many in a row. So if i click the button 4 times and ping fails 4 times the lblcount should display 4. Then if i click it and ping is ok the lblcount goes back to 0.
I've got it displaying 1 after the first fail but then stays. Should i have made this a global variable or a class??
Please Help
I do learn from my mistakes.
Thanks