4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by M.Waqas Aslam
0

Depends what you mean by "field". To clear a text control you set the Text property to the null string as in

TextBox1.Text ""
1

you can do somthing like this . add a module and just call this public sub at your form when ever you want to clear your textboxes or other controls .

   Public Sub ClearAllTextBox(ByVal myControl As Object)
            Dim i As Integer
            For i = 0 To myControl.Controls.Count - 1
                If TypeOf myControl.Controls(i) Is TextBox Then
                    myControl.Controls(i).Text = ""
                ElseIf TypeOf myControl.controls(i) Is MaskedTextBox Then
                    myControl.controls(i).text = ""
                ElseIf TypeOf myControl.controls(i) Is ComboBox Then
                    myControl.controls(i).text = ""
                End If
            Next
        End Sub

just call it like this where you need.

    ClearAllTextBox(me) 
    'or if you have many group boxes or panel then then in place of me just write the name of group box or panel like this 
    ClearAllTextBox(groupbox1)

hope this will help you

Regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.