1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| '------ Dans module de classe : cmdusf
Option Explicit
Public WithEvents cmdgroup As CommandButton
Private Sub cmdgroup_Click()
If usf_1.checkbox.Value = True Then
If cmdgroup.Caption = "cmdB_1" Then usf_2.Show
If cmdgroup.Caption = "cmdB_2" Then usf_3.Show
If cmdgroup.Caption = "cmdB_3" Then usf_4.Show
If cmdgroup.Caption = "cmdB_4" Then usf_5.Show
Else
MsgBox "Veuilez choisir une action", vbInformation, "Choix obliqatoire"
End If
End Sub
'------ Dans l'userform principale : usf_1
Option Explicit
Dim Buttons() As New cmdusf
Private Sub UserForm_Initialize()
Dim Ctrl As Control
Dim Count As Integer
For Each Ctrl In usfmain.Controls
If TypeName(Ctrl) = "CommandButton" Then
Count = Count + 1
ReDim Preserve Buttons(1 To Count)
Set Buttons(Count).cmdgroup = Ctrl
End If
Next
End Sub |
Partager