简化一点吧。 
一个Form,一个按扭, 
一个两级菜单(第一级名称为a,不可见;  第二级名称为mnuColumn,索引为0,即为菜单数组) 
'******** Form中代码如下,是可行的,可以加上10个子菜单 
Private Sub Command1_Click() 
'    setMenu1 mnuColumn  '调用模块中的代码说类型不匹配 
    setMenu 
    PopupMenu a 
End Sub '*********想把下面这一段过程写到模块中
Sub setMenu() 
    Dim i As Integer 
    '如果已加载,不再重复加载 
    If mnuColumn.UBound <= 1 Then 
        For i = 0 To 10 
            If i >= 1 Then 
                Load mnuColumn(i) 
            End If 
            mnuColumn(i).Visible = True 
            mnuColumn(i).Caption = i 
            mnuColumn(i).Checked = True 
        Next i 
    End If 
End Sub '*****在模块中,我是这样写的,行不通
Public Sub setMenu1(mnuColumn As Menu) 
    Dim i As Integer 
    '如果已加载,不再重复加载 
    If mnuColumn.UBound <= 1 Then 
        For i = 0 To 10 
            If i >= 1 Then 
                Load mnuColumn(i) 
            End If 
            mnuColumn(i).Visible = True 
            mnuColumn(i).Caption = i 
        Next i 
    End If 
End Sub 

解决方案 »

  1.   

    Public Sub setMenu1(mnuColumn As Variant)
      

  2.   

    Public Sub setMenu(mnuColumn As Object)
      

  3.   

    Public Sub setMenu1(mnuColumn As Object)
      

  4.   


    Public Sub setMenu1(mnuColumn As Object)
      

  5.   

    也可以
    Public Sub setMenu1(mnuColumn)你要传递的不是menu,而是menu数组
    但控件数组和变量数组传递不同参考这个
    VB中的函数可以使用数组形参,但是却不能传递控件数组,原因是VB中的控件数组和数组本身的构造方式不太一样,虽然同是在内存中顺序排列,但是调用方法却有小小区别,控件数组的使用更象是一个集合。数组的使用
    仅仅只能通过Lboun和Ubound函数来获取数组上下标,而控件数组则可使用control.Lbound,control.ubound属性来获取上下标。数组中访问其元素只能使用Arr(Index)的方式,但控件数组则还可以通过control.item(index)来访问。由于这点小小的不同,造成了控件数组不能当作函数参数传递的问题。
    现在我们通过2种方式来解决!!2种方式实现各不相同,所能应用的范围也不一样。
    第一种使用对象数组的方法:(例子说明)
    private sub SendControls()
        Dim Arr_Chk() as CheckBox
        Dim Int_I As Integer    ReDim Arr_Chk(Chk_Tmp.Lbound To Chk_Tmp.Ubound)
        For Int_I =Chk_Tmp.Lbound to Chk_Tmp.Ubound
            Set Arr_Chk(Int_I)=Chk_Tmp.Item(Int_I)
        next     Call TestControls(Arr_Chk)
    end subprivate sub TestControls(ByRef TestControls() As CheckBox)
        Dim Int_I as Integer
        For Int_I=Lbound(TestControls) To Ubound(TestControls)
            debug.pring TestControls(Int_I).Name & "    " & TestControls(Int_I).Value
        next
    End Sub第二种方式,传递控件数组中一个元素。(这种方式有点取巧)
    Private Sub SendControls()
        call TestControls(Chk_Tmp.Item(Chk_Tmp.Lbound))
    end subPrivate Sub TestControls(byval TestControl as CheckBox)    Dim TmpControl as Object     For Each TmpControl In Controls
             If TmpControl.Name=TestControl.Name Then
                 Debug.Print TmpControl.Name & "   " & TmpControl.Value
             end if
         Next
    End Sub