能不能帮我写个可重复使用的函数把窗体中所有的文本框置空?

解决方案 »

  1.   

    Private Sub Form_Load()
    clearText
    End SubPrivate Sub clearText()
    Dim t As TextBox
    For Each t In Me.Controls
        t.Text = ""
    Next
    End Sub
      

  2.   

    Public Sub ClearAllTextBox(frm As Form)    Dim c As Object
        For Each c In frm
            If TypeOf c Is TextBox Then
                c.Text = vbNullString
            End If
        NextEnd Sub
      

  3.   

    Sub Cleratext()
    Dim txt As Object
    For Each txt In Me.Controls
    If TypeOf txt Is TextBox Then txt = ""
    Next
    End SubPrivate Sub Command1_Click()
    Cleratext
    End Sub