比如說,在一個窗體中有很多控件,你怎樣知道有沒有Button

解决方案 »

  1.   

    TypeOf 也可以,如:
    Sub ControlProcessor(MyControl As Control)
       If TypeOf MyControl Is CommandButton Then
          Debug.Print "You passed in a " & TypeName(MyControl)
       ElseIf TypeOf MyControl Is CheckBox Then
          Debug.Print "You passed in a " & TypeName(MyControl)
       ElseIf TypeOf MyControl Is TextBox Then
          Debug.Print "You passed in a " & TypeName(MyControl)
       End If
    End Sub