一楼正解,不过不完整
把一楼的代码封装成一个函数,参数是容器,然后递归调用
For i As Integer = 0 To GroupBox1.Controls.Count - 1
If GroupBox1.Controls(i).GetType = GetType(TextBox) Then
GroupBox1.Controls(i).Text = ""
End If
Next
在textbox的属性中改,或在load中输入Textbox.text.clear()
'调用ClearText(groupbox1)
Sub ClearText(ByVal obj As Object)
For i As Integer = 0 To obj.Controls.Count - 1
If obj.Controls(i).GetType = GetType(TextBox) Then
obj.Controls(i).Text = ""
End If
Next
End Sub