我的FORM1上有50个文本框 我想一次性全部清空 但不要一个个的输 text1.text=""
有什么好的办法吗? 谢了

解决方案 »

  1.   

    如果这50个文本框是控件数组,可以用以下方法:
    Private Sub Command2_Click()
        Dim t As TextBox
        For Each t In Text1
            t.Text = ""
        Next
    End Sub
    如果不用控件数组
    Private Sub Command1_Click()
        Dim t As Object
        For Each t In Me.Controls
             If TypeName(t) = "TextBox" Then t.Text = ""
        Next
    End Sub
    这将清除窗体上所有textbox中的内容。
      

  2.   

    Dim t as TextBox  For each t in Form1
        t.Text = ""
      Next t
      

  3.   

            For i = 0 To (Controls.Count - 1)
               If TypeOf Controls(i) Is TextBox Then
                '相关文本框操作
               End If
            Next