我有一个像这样的子:
Private Sub mysub (parameters) handles control1.mousemove, control1.mousedown, control2.mousemove, control2.mousedown
'Statements
End Sub
我知道什么控制激活sub但是我想知道什么事件激活了sub(例如control2激活sub但我想知道事件mousemove或mousedown)
由于
答案 0 :(得分:1)
您无法直接告诉您调用事件处理程序的原因。你能做的最好的事情是:
Private Sub MouseMove_Handler(sender As Object, e As MouseEventArgs) Handles control1.mousemove, control2.mousemove
MouseCommonCode(sender, e, "MouseMove")
End Sub
Private Sub MouseDown_Handler(sender As Object, e As MouseEventArgs) Handles control1.mousedown, control2.mousedown
MouseCommonCode(sender, e, "MouseDown")
End Sub
Private Sub MouseCommonCode(sender As Object, e As MouseEventArgs, caller As String)
'Common Statements
End Sub
虽然,我会说这是一个非常奇怪的请求,似乎可能是一个更好的方式去做你想做的事情。< / p>
答案 1 :(得分:0)
我是那种人,所以我在这里走了一段路。 你不能做这样的事情:
Private Sub mysub1 (parameters) handles control1.mousemove
'Statements ...
End Sub
Private Sub mysub2 ( parameters) handles control1.mousedown
'Statements ...
End Sub
等等?