Simplifier un bout de code

cs_Baboune1 Messages postés 13 Date d'inscription lundi 31 décembre 2001 Statut Membre Dernière intervention 28 mars 2002 - 18 mars 2002 à 20:27
cs_Baboune1 Messages postés 13 Date d'inscription lundi 31 décembre 2001 Statut Membre Dernière intervention 28 mars 2002 - 20 mars 2002 à 21:14
Salut,
Quelqu'un saurait me dire comment simplifier ce code :

FormCalendrier.Bouton1.Caption = Calendar(1, 1)
FormCalendrier.Bouton2.Caption = Calendar(1, 2)
FormCalendrier.Bouton3.Caption = Calendar(1, 3)
FormCalendrier.Bouton4.Caption = Calendar(1, 4)
FormCalendrier.Bouton5.Caption = Calendar(1, 5)
FormCalendrier.Bouton6.Caption = Calendar(1, 6)
FormCalendrier.Bouton7.Caption = Calendar(1, 7)
FormCalendrier.Bouton8.Caption = Calendar(2, 1)
FormCalendrier.Bouton9.Caption = Calendar(2, 2)
FormCalendrier.Bouton10.Caption = Calendar(2, 3)
FormCalendrier.Bouton11.Caption = Calendar(2, 4)
FormCalendrier.Bouton12.Caption = Calendar(2, 5)
FormCalendrier.Bouton13.Caption = Calendar(2, 6)
FormCalendrier.Bouton14.Caption = Calendar(2, 7)

FormCalendrier.Bouton X.Caption= Calendar(Y, Z)
ne fonctionne pas !

Merci de votre aide.

5 réponses

Neo.balastik Messages postés 796 Date d'inscription jeudi 17 mai 2001 Statut Membre Dernière intervention 5 mai 2009 7
19 mars 2002 à 08:22
Salut,

Essaye cela:

Dim Counter As Byte
Dim Y As Byte
Dim Z As Byte

Y = 1

For i = 1 To 14

If i > 7 Then Y = 2 If Z 8 Then Z 0

Z = Z + 1

FormCalendrier.Controls("Bouton" & Trim$(Str$(i))).Caption = Calendar(Y, Z)

Next i

Tchao

NéoB
0
Schouly Messages postés 45 Date d'inscription dimanche 21 janvier 2001 Statut Membre Dernière intervention 6 octobre 2006
19 mars 2002 à 12:05
Je serai de toi je créerai un tableau d'élément ...

Tu crée un Bouton et tu lui met l'index 1 ... ensuite

tu fais des copier coller de ton bouton ... ça donnera une succesion d'index. tu pourras l'utiliser comme :

FormCalendrier.Bouton(14).Caption = Calendar(2, 7)

FormCalendrier.Bouton(X).Caption = Calendar(2, 7)
0
Neo.balastik Messages postés 796 Date d'inscription jeudi 17 mai 2001 Statut Membre Dernière intervention 5 mai 2009 7
19 mars 2002 à 12:10
Salut,

Pour ton information, il s'agit de l'environnement Excel et non VB. Il n'est pas possible de créer des tableaux de contrôles dans Excel contrairement à VB...

Alors ma méthode reste d'actualité !

Tchao

NéoB
0
Schouly Messages postés 45 Date d'inscription dimanche 21 janvier 2001 Statut Membre Dernière intervention 6 octobre 2006
19 mars 2002 à 18:48
Excuse ...

j'ai vu nul part qu'il s'agissait de VBA ... mais si oui t'as entièrement raison ...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Baboune1 Messages postés 13 Date d'inscription lundi 31 décembre 2001 Statut Membre Dernière intervention 28 mars 2002
20 mars 2002 à 21:14
Tout est dans le titre :)

Comme d'habitude, il y a toujours quelqu’un pour aider un apprenti codeur dans le besoin.

Ne changer rien.
0
Rejoignez-nous