将下列代码复制到模块中,并按F5运行,然后打开“窗体1”,做一些动作即可。
Function setEvent()
Dim p As Property
For Each p In Forms("窗体1").Properties
If Left(p.Name, 2) = "On" _
Or Left(p.Name, 5) = "After" _
Or Left(p.Name, 6) = "Before" Then
p.Value = "=msgbox('" & p.Name & "')"
End If
Next p
End Function
Function resumeEvent()
Dim p As Property
For Each p In Forms("窗体1").Properties
If Left(p.Name, 2) = "On" _
Or Left(p.Name, 5) = "After" _
Or Left(p.Name, 6) = "Before" Then
p.Value = ""
End If
Next p
End Function