Affiliates


Identify textboxes through looping statement

Looping objects are different from other datatype.
This method of looping statement are used to identify each object as any kind of object based in a form

a very simple code to track each object and manipulate each data as you need.


Dim ctrl As Control
 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ctrl As Control
        For Each ctrl In Panel1.Controls
            If (ctrl.GetType() Is GetType(TextBox)) Then
                Dim txt As TextBox = CType(ctrl, TextBox)
                'txt.BackColor = Color.LightYellow
                txtEmplty(txt)
            End If
        Next
    End Sub
Private Function txtEmplty(ByVal objTxt As Object)
        Select Case objTxt.Text
            Case Is = "ServerName"
                txtServer.ForeColor = Color.Red
            Case Is = "UserName"
                txtUser.ForeColor = Color.Red
            Case Is = "PassWord"
                txtPass.ForeColor = Color.Red
            Case Is = "Port"
                txtPort.ForeColor = Color.Red
        End Select
        Return 0
    End Function

Comments

Popular posts from this blog

Fixed by using cmd: USB drive unusable, unformattable, and reporting 0 bytes capacity