I have a winsock that checks to see if 5 servers are online. All 5 servers are entered by the user and some may not be used. Each Server has a Textbox for the address, Another for the Port, and a label for the Status. So it checks all 5 except the ones that dont have text in them here is the code:
Code:
Public Class Form1
    Public Current As Integer
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Connect()
    End Sub
    Private Sub Connect()
        If Not txtAddress1.Text = "" Then
            If Not txtPort1.Text = "" Then
                Current = 1
                AxWinsock1.Close()
                AxWinsock1.RemoteHost = txtAddress1.Text
                AxWinsock1.RemotePort = txtPort1.Text
                AxWinsock1.Connect()
                lblStatus1.Text = "OFFLINE"
                lblStatus1.ForeColor = Color.Red
            End If
        End If
        If Not txtAddress2.Text = "" Then
            If Not txtPort2.Text = "" Then
                Current = 2
                AxWinsock1.Close()
                AxWinsock1.RemoteHost = txtAddress2.Text
                AxWinsock1.RemotePort = txtPort2.Text
                AxWinsock1.Connect()
                lblStatus2.Text = "OFFLINE"
                lblStatus2.ForeColor = Color.Red
            End If
        End If
    End Sub

    Private Sub AxWinsock1_ConnectEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWinsock1.ConnectEvent
        If Current = 1 Then
            lblStatus1.Text = "ONLINE"
            lblStatus1.ForeColor = Color.Green
        ElseIf Current = 2 Then
            lblStatus2.Text = "ONLINE"
            lblStatus2.ForeColor = Color.Green
        End If


    End Sub
End Class