VB.Net .Clear() or txtbox.Text = “” textbox clear methods

后端 未结 8 772
囚心锁ツ
囚心锁ツ 2021-01-11 13:49

Not far into programming and just joined this forum of mighty company so this is a silly question, but what is the best way to clear textboxes in VB.Net and what is the diff

8条回答
  •  离开以前
    2021-01-11 14:25

    Public Sub EmptyTxt(ByVal Frm As Form)
        Dim Ctl As Control
        For Each Ctl In Frm.Controls
            If TypeOf Ctl Is TextBox Then Ctl.Text = ""
            If TypeOf Ctl Is GroupBox Then
                Dim Ctl1 As Control
                For Each Ctl1 In Ctl.Controls
                    If TypeOf Ctl1 Is TextBox Then
                        Ctl1.Text = ""
                    End If
                Next
            End If
        Next
    End Sub
    

    add this code in form and call this function

    EmptyTxt(Me)
    

提交回复
热议问题