Dim objTest as Object
Select Case str1
Case "Text1"
    Set objTest=Text1
Case "Text2"
    Set objTest=Text2
Case Else
    Set objTest=Nothing
End Select然后引用objTest进行操作.   

解决方案 »

  1.   

    是想实现text1.setfocus吗?
    定义错了吧?应该:
    Dim text1 As TextBox
    然后callbyname中参数1的类型设为control
      

  2.   

    参考这个
    Private Sub Command1_Click()
        Dim objTest As Object
        Dim strT1 As String
        Dim strT2 As String
        strT1 = Text1.Text
        strT2 = Time
        For Each objTest In Form1
            If objTest.Name = strT1 Then
                w ByVal objTest, strT2
                Exit For
            End If
        Next
    End Sub
    Private Function w(ByVal l As Object, l2 As String)
        l.Caption = l2
    End Function