|
-
Jan 22nd, 2008, 11:44 PM
#1
Thread Starter
Lively Member
[2008] How can i do this
Sorry for the non descriptive title but i dunno how to explain what i wanna do.
basically i have a program that pings my servers at work every minute and displays the reply time and status
heres what it looks like

now my problem is all the fields are static, i have say 14 fields for servers, what id like is to make a selection box to how many im going to have, say 1 or 20 and it will adjust it accordingly.
now heres the code im using (its a mess)
vb Code:
Private Sub btnCheckStatus_Click1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckStatus.Click
strfail = "Failed Ping"
Me.txtserver1Status.Text = "down"
Me.txtserver1Status.ForeColor = Color.Red
Me.server1_responsetime.Text = ("")
If My.Settings.server1_ip <> String.Empty Then
Dim MyPing As New System.Net.NetworkInformation.Ping
Dim MyPingResult As System.Net.NetworkInformation.PingReply = MyPing.Send(My.Settings.server1_ip)
If MyPingResult.Status = Net.NetworkInformation.IPStatus.Success Then
log_pings(Me.server1_responsetime.Text, My.Settings.server1_name)
Me.txtserver1Status.Text = "Up"
Me.server1_responsetime.Text = (MyPingResult.RoundtripTime.ToString & " ms")
Me.txtserver1Status.ForeColor = Color.Lime
Else
log_database(Date.Now.ToShortTimeString, Date.Now.ToShortDateString, My.Settings.server1_name, strfail)
Me.txtserver1Status.Text = "down"
Me.txtserver1Status.ForeColor = Color.Red
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(5000) '5 second display
If My.Settings.server1emailalert = True Then
send_email()
End If
End If
End If
End Sub
i have this code copied and pasted 14 times to run when when the same button is clicked, i just name them Private Sub btnCheckStatus_Click1, 2, 3, 4 etc.
how hard will it be for me to squeeze all this code into 1 sub that runs when the button is clicked and will allow me to change how many servers to display.
thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|