Dim Ctrl As ControlFor Each Ctrl In Me.ControlsIf TypeOf Ctrl Is TextBox ThenEnd IfNext
只获取frame1里面的textbox: Private Sub Command1_Click() Dim t As Control For Each t In Me.Controls If TypeOf t Is TextBox And t.Container Is Frame1 Then Debug.Print t.Name End If Next t End Sub
Private Sub Command1_Click()
Dim t As Control
For Each t In Me.Controls
If TypeOf t Is TextBox And t.Container Is Frame1 Then
Debug.Print t.Name
End If
Next t
End Sub