你可以设置textbox为控件数组,然后作一个循环,把它们都清空就行了! 4个textbox控件(数组),1个command控件! Private Sub Command1_Click() Dim i As Integer For i = 0 To 3 Text1(i).Text = "" Next i End Sub
'试试这个 Dim Ctrl As Control For Each Ctrl In Me.Controls If Left(Ctrl.Name, 3) = "txt" Then Ctrl.Text = "" End If Next
'Try It Dim Ctrl As Control For Each Ctrl In Me.Controls If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = "" End If Next
控件数组或者for each typename(control)=文本框控件
用Typeof语句也可以的,推荐使用 Dim Ctrl As Control For Each Ctrl In Me.Controls If Typeof Ctrl is TextBox Then Ctrl.Text = "" End If Next
.
.
.
.
text6.text=""
逐个清一下就行了.
text(i)=""
next
4个textbox控件(数组),1个command控件!
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To 3
Text1(i).Text = ""
Next i
End Sub
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If Left(Ctrl.Name, 3) = "txt" Then
Ctrl.Text = ""
End If
Next
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then
Ctrl.Text = ""
End If
Next
For Each Ctrl In Me.Controls
If Typeof Ctrl is TextBox Then
Ctrl.Text = ""
End If
Next