一.普通方法
在程序中若为A控件的某个事件编写了程序,但又需要在B控件的某个事件被触发的情况下运行A控件的程序,可以用下列代码:
Me.btnA_click(
nothing,nothing)
请VB6程序员注意此变化。
二.VB2005中的新方法
Private
Sub Label2_MouseEnter(
ByVal sender
As Object,
ByVal e
As System.EventArgs)
Handles Label2.MouseEnter, PictureBox4.MouseEnter
Label2.ForeColor = Color.Red
End Sub
Label2.ForeColor = Color.Red
End Sub
注意在
Handles
后边有两个用逗号分开的事件Label2.MouseEnter和PictureBox4.MouseEnter,这表示上述两个控件的这MouseEnter事件被触发时,都将运行此代码。