Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
因为我要用的是控件数组,那怎么才能传进index值呢?
新建一个用户控件,控件里边包含以下程序: Option Explicit Dim L As Boolean #If L Then Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) #Else Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Private Sub UserControl_AmbientChanged(PropertyName As String) On Error GoTo MyError L = False If UserControl.Extender.Index > 0 Then L = True MyError: End Sub#End If Private Sub UserControl_Initialize() On Error GoTo MyError L = False If UserControl.Extender.Index > 0 Then L = True MyError: End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) On Error Resume Next If L Then RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y) Else RaiseEvent MouseUp(Button, Shift, X, Y) End If End Sub
错了,应该是这样: Option Explicit Dim L As Boolean #If L Then Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) #Else Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) #End If Private Sub UserControl_AmbientChanged(PropertyName As String) On Error GoTo MyError L = False If UserControl.Extender.Index > 0 Then L = True MyError: End Sub Private Sub UserControl_Initialize() On Error GoTo MyError L = False If UserControl.Extender.Index > 0 Then L = True MyError: End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) On Error Resume Next If L Then RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y) Else RaiseEvent MouseUp(Button, Shift, X, Y) End If End Sub
还错,应该是这样: Option Explicit Dim L As Boolean #If L Then Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) #Else Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) #End If Private Sub UserControl_AmbientChanged(PropertyName As String) On Error GoTo MyError L = False If UserControl.Extender.Index >= 0 Then L = True MyError: End Sub Private Sub UserControl_Initialize() On Error GoTo MyError L = False If UserControl.Extender.Index >= 0 Then L = True MyError: End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) On Error Resume Next If L Then RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y) Else RaiseEvent MouseUp(Button, Shift, X, Y) End If End Sub
Option Explicit
Dim L As Boolean
#If L Then
Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
#Else
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Private Sub UserControl_AmbientChanged(PropertyName As String)
On Error GoTo MyError
L = False
If UserControl.Extender.Index > 0 Then L = True
MyError:
End Sub#End If
Private Sub UserControl_Initialize()
On Error GoTo MyError
L = False
If UserControl.Extender.Index > 0 Then L = True
MyError:
End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If L Then
RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y)
Else
RaiseEvent MouseUp(Button, Shift, X, Y)
End If
End Sub
Option Explicit
Dim L As Boolean
#If L Then
Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
#Else
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
#End If
Private Sub UserControl_AmbientChanged(PropertyName As String)
On Error GoTo MyError
L = False
If UserControl.Extender.Index > 0 Then L = True
MyError:
End Sub
Private Sub UserControl_Initialize()
On Error GoTo MyError
L = False
If UserControl.Extender.Index > 0 Then L = True
MyError:
End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If L Then
RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y)
Else
RaiseEvent MouseUp(Button, Shift, X, Y)
End If
End Sub
Option Explicit
Dim L As Boolean
#If L Then
Public Event MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
#Else
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
#End If
Private Sub UserControl_AmbientChanged(PropertyName As String)
On Error GoTo MyError
L = False
If UserControl.Extender.Index >= 0 Then L = True
MyError:
End Sub
Private Sub UserControl_Initialize()
On Error GoTo MyError
L = False
If UserControl.Extender.Index >= 0 Then L = True
MyError:
End SubPrivate Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
If L Then
RaiseEvent MouseUp(UserControl.Extender.Index, Button, Shift, X, Y)
Else
RaiseEvent MouseUp(Button, Shift, X, Y)
End If
End Sub
为什么?