新建From1(窗体),新建Command1-2(按钮CommandButton),代码:
Private Sub Command1_Click() For i = 1 To 2 Debug.Print Controls("Text" & i).Text Next End Sub
运行结果:
Text1 Text2