Hello everyone, I'm fairly new to Visual Basic. My background is
working with MS Access and SQL Backends with use of VBA code.

I'm trying to create a very simple program that pings a server and if
it the ping test fails x number of times in a row for an x minute
period then Do Something.

When I run the following code inside of a timer control, it keeps
eating up ram more and more as it ticks. As you can see from below,
the code is now in the Form1_Load but of course this only runs once
and then stops. Thanks for the help.

Public Class ServerMonitor
Private Shared alarmCounter As Integer = 0

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'600000 = 10 minutes pingtime, 3600000 = 60 minutes pingtime
If My.Computer.Network.Ping("192.168.2.4", 10000) Then
TextBox1.Text = "Server pinged successfully."
alarmCounter = 0

Else
alarmCounter += 1
TextBox1.Text = "Server TIMED OUT " & alarmCounter & " TIMES!"

End If

If alarmCounter = 5 Then
alarmCounter = 0
TextBox1.Text = "5 counts. Failed!"
End If

I think I need this to loop but I'm not sure. Any advise would be
great. Thanks!

Reply via email to