写一个遍历窗体中的按纽功能的函数,放在模块中,请问该怎么写?

解决方案 »

  1.   

    Public Function getbuttons(mform As Form)
        Dim a
        For Each a In mform.Controls
            If TypeName(a) = "CommandButton" Then
                Debug.Print a.Caption '换成你需要的语句
            End If
         Next
    End Function'调用
     getbuttons Form1
      

  2.   

    Public Function InitCtrl(lpara As Form) As LongOn Error Resume NextFor Each mycontrols In lpara
      if TypeName(mycontrols)="CommandButton" then
         msgbox mycontrols.caption
      end ifNext
    End Function
      

  3.   

    rainstormmaster(rainstormmaster)  是正确的
      

  4.   

    如不是自己的窗口用getwindow