Sub callBack(Optional param As String)
'Static i As Integer
i = i + 1
If i > 1 Then Exit Sub
If param = "" Then
MsgBox i & " Appel sans paramètre"
Else
MsgBox i & " Appel avec paramètre : " & param
End If
End Sub
en déclarant Public i As Integer et mettre i =0 dans la création de menu
Du coup on peut se passer de variable globale (beurk ) en modifiant le callBack comme suit :
Code:
Sub callBack(Optional param As String = "")
Static i As Integer
If param = "" Then
MsgBox i & " Appel sans paramètre"
i = i + 1
Else
If i = 0 Then
MsgBox i & " Appel avec paramètre : " & param
i = i + 1
Else
i = 0
End If
End If
End Sub
Ces deux solutions résolvent le problème, mais le mystère demeure sur cet étrange comportement