![]() |
|
Forum
|
|
|
#1 (permalink) |
|
XLDnaute Barbatruc
Date d'inscription: juin 2005
Localisation: RENNES
Version Excel : Excel 2000 (PC)
Messages: 6 771
|
Bonjour à tous
Voila le problème: Affecter une valeur différente à CommandButton selon clic 1clic=1, 2clic=2, 3clic=3 enusite on revient à 1 et ainsi de suite Voila ou j'en suis Private Sub CommandButton1_Click() z = CommandButton1.Caption Select Case z Case 1 CommandButton1.Caption = 2 Case 2 CommandButton1.Caption = 3 Case 3 CommandButton1.Caption = 1 End Select End Sub Private Sub UserForm_Initialize() CommandButton1.Caption = 1 End Sub Ca ne fonctionne pas
__________________
Cordialement, __________________ JM Addict |
|
|
|
| ANNONCES | |||
|
|
|
|
#2 (permalink) |
|
XLDnaute Barbatruc
Date d'inscription: février 2005
Localisation: Saint-Etienne
Version Excel : Excel XP (PC)
Messages: 4 453
|
Bonjour staple, le forum
essaye comme ceci : Private Sub CommandButton1_Click() n = n + 1 If n > 3 Then n = 1 CommandButton1.Caption = n End Sub en déclarant public la variable n dans un module standard (public n as byte) salut |
|
|
|
|
|
#3 (permalink) |
|
XLDnaute Barbatruc
Date d'inscription: juin 2005
Localisation: RENNES
Version Excel : Excel 2000 (PC)
Messages: 6 771
|
Merci cela fonctionne
Et si on veut remplacer par des lettres? exemple: 1) clic = VU 2) clic = A VOIR 3) clic= N/R J'ai pensé à pour (ABC) x = 65 n = Chr(x) + 1 If n > Chr(67) Then n = Chr(65) CommandButton1.Caption = n mais ca ne fonctionne pas
__________________
Cordialement, __________________ JM Addict |
|
|
|
|
|
#4 (permalink) |
|
XLDnaute Barbatruc
Date d'inscription: février 2005
Localisation: Saint-Etienne
Version Excel : Excel XP (PC)
Messages: 4 453
|
re
Alors repart avec le systeme du selct case : Private Sub CommandButton1_Click() n = n + 1 If n > 3 Then n = 1 Select Case n Case 1: CommandButton1.Caption = 'VU' Case 2: CommandButton1.Caption = 'A VOIR' Case 3: CommandButton1.Caption = 'N/R' End Sub salut |
|
|
|
|
|
#5 (permalink) |
|
XLDnaute Barbatruc
Date d'inscription: juin 2005
Localisation: RENNES
Version Excel : Excel 2000 (PC)
Messages: 6 771
|
Merci Hervé
Effectivement Private Sub CommandButton1_Click() n = n + 1 If n > 3 Then n = 1 Select Case n Case 1: CommandButton1.Caption = 'VU' Case 2: CommandButton1.Caption = 'A VOIR' Case 3: CommandButton1.Caption = 'N/R' End Select End Sub Private Sub UserForm_Initialize() CommandButton1.Caption = 'A' End Sub Mais je comprends pas pourquoi parfois il faut cliquer deux fois de suite pour obtenir le changement de valeur
__________________
Cordialement, __________________ JM Addict |
|
|
|
| ANNONCES | |
![]() |
| Liens sociaux |
| Outils de la discussion | |
|
|