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:
  1. Private Sub btnCheckStatus_Click1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckStatus.Click
  2.         strfail = "Failed Ping"
  3.         Me.txtserver1Status.Text = "down"
  4.         Me.txtserver1Status.ForeColor = Color.Red
  5.         Me.server1_responsetime.Text = ("")
  6.         If My.Settings.server1_ip <> String.Empty Then
  7.             Dim MyPing As New System.Net.NetworkInformation.Ping
  8.             Dim MyPingResult As System.Net.NetworkInformation.PingReply = MyPing.Send(My.Settings.server1_ip)
  9.             If MyPingResult.Status = Net.NetworkInformation.IPStatus.Success Then
  10.                 log_pings(Me.server1_responsetime.Text, My.Settings.server1_name)
  11.                 Me.txtserver1Status.Text = "Up"
  12.                 Me.server1_responsetime.Text = (MyPingResult.RoundtripTime.ToString & " ms")
  13.                 Me.txtserver1Status.ForeColor = Color.Lime
  14.             Else
  15.                 log_database(Date.Now.ToShortTimeString, Date.Now.ToShortDateString, My.Settings.server1_name, strfail)
  16.                 Me.txtserver1Status.Text = "down"
  17.                 Me.txtserver1Status.ForeColor = Color.Red
  18.                 NotifyIcon1.Visible = True
  19.                 NotifyIcon1.ShowBalloonTip(5000) '5 second display
  20.                 If My.Settings.server1emailalert = True Then
  21.                     send_email()
  22.                 End If
  23.             End If
  24.         End If
  25.     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.