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
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
Dim a
For Each a In mform.Controls
If TypeName(a) = "CommandButton" Then
Debug.Print a.Caption '换成你需要的语句
End If
Next
End Function'调用
getbuttons Form1
if TypeName(mycontrols)="CommandButton" then
msgbox mycontrols.caption
end ifNext
End Function