Précédent   Forum du club des développeurs et IT Pro > Autres langages > Général Visual Basic 6 et VBScript > VB 6 et antérieur
VB 6 et antérieur Visual basic 6 et versions antérieures. Avant de poster -> La FAQ VB6, Les tutoriels VB
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 16/12/2012, 13h00   #1
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
Par défaut code trop lent

Bonjour à tous,
he bien oui c'est encore moi ; décidément je suis nul
Cette fois-ci mon code fonctionne mais il est bien trop lent.
J'ai le flexgrid2 dans lesquels j'inscris les date (il me sert d'entête de colonne, et si la date correspond à un weekend ou un jour férié, je colore les colonnes du flexgrid1 (2 colonne à chaque fois car le tableau est en 1/2 journée)
le hic c'est qu'il faut au moins 10 bonnes secondes pour effectuer l'oppération et le tableau n'a que 40 lignes, quand je l'aurais agrandi à 200, j'aurais le temps d'aller boire le café

voici le code

Code :
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 
Private Sub DTPicker1_Click()
Dim D As Date, W As String
Dim h As Integer, m As Integer, J As Integer, fJourFerie, l As Integer, cl As Long
    Dim tmpDate
 
 
MSFlexGrid2.Row = 0
MSFlexGrid2.Col = 3
D = Me.DTPicker1
 
MSFlexGrid2.Text = Format$(Me.DTPicker1 - 1, "dd/mm/yy")
 
Dim A As Long, B As Long
A = 4
For A = 4 To 52
If A > 4 Then
cl = A - 4 + A
Else
cl = 4
End If
 
'incrémentation de la date
 
'adresse de la date
MSFlexGrid2.Row = 0
MSFlexGrid2.Col = A
'extraction du jour (lettre)
W = WeekdayName(Weekday(D))
'extraction de l'année, du mois et du jour (nombre)
h = Year(D): m = Month(D): J = Day(D)
'calcul du lundi de pâque
 tmpDate = fLundiPaques(h)
'si l'on est un samedi ou un dimanche je colore en jaune les entêtes et les colonnes du tableau
If W = "samedi" Or W = "dimanche" Then
MSFlexGrid2.CellBackColor = &HFFFF&
'j'inscrit samedi ou dimanche en entête
MSFlexGrid2.Text = Format$(W, "dd/mm/yy")
'coloriage du tableau
B = cl
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
 
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
 
Next l
 
 
'1er janvier
ElseIf m = 1 And J = 1 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'1ermai
ElseIf m = 5 And J = 1 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'8 mai
ElseIf m = 5 And J = 8 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'14 juillet
ElseIf m = 7 And J = 14 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'15 aout
ElseIf m = 8 And J = 15 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'tousaint
ElseIf m = 11 And J = 1 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'11 novembre
ElseIf m = 11 And J = 11 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
'noel
ElseIf m = 12 And J = 25 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
Next l
 
 
ElseIf D = tmpDate Then
 
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
For l = 1 To 39
 
MSFlexGrid1.Row = l
MSFlexGrid1.Col = B
MSFlexGrid1.CellBackColor = &HFFFF&
If l = 39 And B = cl Then
l = 0
B = B + 1
End If
 
Next l
Else
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
 
End If
D = D + 1
Fin = Format$(D, "dd/mm/yy")
Next A
End Sub
bien sur c'est du boulot d'amateur, mais au lieu de faire une boucle, s'il y avait moyen de sélectionner la plage de cellule, je pense que ça accélérerait le processus. Mais je n'ai pas trouvé comment faire...

merci pour votre aide


cordialement
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 14h10   #2
iclic
Membre éprouvé
 
Inscription : décembre 2007
Messages : 454
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 454
Points : 497
Points : 497
Bonjour,

Une remarque apprend à coder en retrait pour rendre ton code plus lisible
Exemple ci-dessous
Code :
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
 
Private Sub DTPicker1_Click()
Dim D As Date, W As String
Dim h As Integer, m As Integer, J As Integer, fJourFerie, l As Integer, cl As Long
    Dim tmpDate
 
 
MSFlexGrid2.Row = 0
MSFlexGrid2.Col = 3
D = Me.DTPicker1
 
MSFlexGrid2.Text = Format$(Me.DTPicker1 - 1, "dd/mm/yy")
 
Dim A As Long, B As Long
A = 4
For A = 4 To 52
   If A > 4 Then
       cl = A - 4 + A
            Else
       cl = 4
   End If
 
   'incrémentation de la date
 
   'adresse de la date
   MSFlexGrid2.Row = 0
   MSFlexGrid2.Col = A
   'extraction du jour (lettre)
   W = WeekdayName(Weekday(D))
   'extraction de l'année, du mois et du jour (nombre)
   h = Year(D): m = Month(D): J = Day(D)
   'calcul du lundi de pâque
   tmpDate = fLundiPaques(h)
   'si l'on est un samedi ou un dimanche je colore en jaune les entêtes et les colonnes du tableau
   If W = "samedi" Or W = "dimanche" Then
                MSFlexGrid2.CellBackColor = &HFFFF&
                'j'inscrit samedi ou dimanche en entête
                MSFlexGrid2.Text = Format$(W, "dd/mm/yy")
                'coloriage du tableau
                B = cl
                For l = 1 To 39
 
                  MSFlexGrid1.Row = l
                  MSFlexGrid1.Col = B
                  MSFlexGrid1.CellBackColor = &HFFFF&
 
                  If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                  End If
 
                Next l
 
 
               '1er janvier
             ElseIf m = 1 And J = 1 Then
               MSFlexGrid2.CellBackColor = &HFFFF&
               MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
               For l = 1 To 39
 
                  MSFlexGrid1.Row = l
                  MSFlexGrid1.Col = B
                  MSFlexGrid1.CellBackColor = &HFFFF&
                  If l = 39 And B = cl Then
                           l = 0
                           B = B + 1
                  End If
               Next l
               '1ermai
             ElseIf m = 5 And J = 1 Then
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                    End If
                  Next l
                  '8 mai
              ElseIf m = 5 And J = 8 Then
                 MSFlexGrid2.CellBackColor = &HFFFF&
                 MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                 For l = 1 To 39
 
                   MSFlexGrid1.Row = l
                   MSFlexGrid1.Col = B
                   MSFlexGrid1.CellBackColor = &HFFFF&
                   If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                   End If
                 Next l
                 '14 juillet
              ElseIf m = 7 And J = 14 Then
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                      MSFlexGrid1.Row = l
                      MSFlexGrid1.Col = B
                      MSFlexGrid1.CellBackColor = &HFFFF&
                      If l = 39 And B = cl Then
                             l = 0
                             B = B + 1
                      End If
                   Next l
                   '15 aout
              ElseIf m = 8 And J = 15 Then
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                     MSFlexGrid1.Row = l
                     MSFlexGrid1.Col = B
                     MSFlexGrid1.CellBackColor = &HFFFF&
                     If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                     End If
                   Next l
                   'tousaint
              ElseIf m = 11 And J = 1 Then
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                     MSFlexGrid1.Row = l
                     MSFlexGrid1.Col = B
                     MSFlexGrid1.CellBackColor = &HFFFF&
                     If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                     End If
                  Next l
                  '11 novembre
             ElseIf m = 11 And J = 11 Then
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
                  Next l
                  'noel
             ElseIf m = 12 And J = 25 Then
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
                  Next l
 
 
            ElseIf D = tmpDate Then
 
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
 
                  Next l
            Else
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
 
   End If
   D = D + 1
   Fin = Format$(D, "dd/mm/yy")
Next A
End Sub
iclic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 14h34   #3
iclic
Membre éprouvé
 
Inscription : décembre 2007
Messages : 454
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 454
Points : 497
Points : 497
... et remplacer tes 'elseif par un 'select case beaucoup plus performant
Code :
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
 
 
Private Sub DTPicker1_Click()
Dim D As Date, W As String
Dim h As Integer, m As Integer, j As Integer, fJourFerie, l As Integer, cl As Long
    Dim tmpDate
 
 
MSFlexGrid2.Row = 0
MSFlexGrid2.Col = 3
D = Me.DTPicker1
 
MSFlexGrid2.Text = Format$(Me.DTPicker1 - 1, "dd/mm/yy")
 
Dim A As Long, B As Long
A = 4
For A = 4 To 52
   If A > 4 Then
       cl = A - 4 + A
            Else
       cl = 4
   End If
 
   'incrémentation de la date
 
   'adresse de la date
   MSFlexGrid2.Row = 0
   MSFlexGrid2.Col = A
   'extraction du jour (lettre)
   W = WeekdayName(Weekday(D))
   'extraction de l'année, du mois et du jour (nombre)
   h = Year(D): m = Month(D): j = Day(D)
   'calcul du lundi de pâque
   tmpDate = fLundiPaques(h)
   'si l'on est un samedi ou un dimanche je colore en jaune les entêtes et les colonnes du tableau
   If W = "samedi" Or W = "dimanche" Then
                MSFlexGrid2.CellBackColor = &HFFFF&
                'j'inscrit samedi ou dimanche en entête
                MSFlexGrid2.Text = Format$(W, "dd/mm/yy")
                'coloriage du tableau
                B = cl
                For l = 1 To 39
 
                  MSFlexGrid1.Row = l
                  MSFlexGrid1.Col = B
                  MSFlexGrid1.CellBackColor = &HFFFF&
 
                  If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                  End If
 
                Next l
    End If
 
    Select Case m And j
               '1er janvier
         Case m = 1 And j = 1
               MSFlexGrid2.CellBackColor = &HFFFF&
               MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
               For l = 1 To 39
 
                  MSFlexGrid1.Row = l
                  MSFlexGrid1.Col = B
                  MSFlexGrid1.CellBackColor = &HFFFF&
                  If l = 39 And B = cl Then
                           l = 0
                           B = B + 1
                  End If
               Next l
               '1ermai
          Case m = 5 And j = 1
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                    End If
                  Next l
                  '8 mai
           Case m = 5 And j = 8
                 MSFlexGrid2.CellBackColor = &HFFFF&
                 MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                 For l = 1 To 39
 
                   MSFlexGrid1.Row = l
                   MSFlexGrid1.Col = B
                   MSFlexGrid1.CellBackColor = &HFFFF&
                   If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                   End If
                 Next l
                 '14 juillet
           Case m = 7 And j = 14
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                      MSFlexGrid1.Row = l
                      MSFlexGrid1.Col = B
                      MSFlexGrid1.CellBackColor = &HFFFF&
                      If l = 39 And B = cl Then
                             l = 0
                             B = B + 1
                      End If
                   Next l
                   '15 aout
          Case m = 8 And j = 15
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                     MSFlexGrid1.Row = l
                     MSFlexGrid1.Col = B
                     MSFlexGrid1.CellBackColor = &HFFFF&
                     If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                     End If
                   Next l
                   'tousaint
          Case m = 11 And j = 1
                   MSFlexGrid2.CellBackColor = &HFFFF&
                   MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                   For l = 1 To 39
 
                     MSFlexGrid1.Row = l
                     MSFlexGrid1.Col = B
                     MSFlexGrid1.CellBackColor = &HFFFF&
                     If l = 39 And B = cl Then
                          l = 0
                          B = B + 1
                     End If
                  Next l
                  '11 novembre
          Case m = 11 And j = 11
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
                  Next l
                  'noel
          Case m = 12 And j = 25
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
                  Next l
 
 
           Case Else
               If D = tmpDate Then
 
                  MSFlexGrid2.CellBackColor = &HFFFF&
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
                  For l = 1 To 39
 
                    MSFlexGrid1.Row = l
                    MSFlexGrid1.Col = B
                    MSFlexGrid1.CellBackColor = &HFFFF&
                    If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                    End If
 
                  Next l
                              Else
                  MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
 
                End If
   End Select
   D = D + 1
   Fin = Format$(D, "dd/mm/yy")
Next A
End Sub
iclic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 15h17   #4
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
je ne maitrise pas bien les select case et comme je ne vois pas ce que ça fait de plus que des if, je ne les utilises jamais. J'ai essayé ton code mais pas de différence de rapidité, du moins en apparence.
J'ai déjà fais le même tableau en VBA dans excel et il est tellement lent qu'il en devient inutilisable. J'espérais qu'avec VB6 j'arriverais à contourner le problème, mais les boucles sont tout aussi lentes qu'en vba ; pourtant le code n'est pas si long que ça 6 ou 7 ligne pour une boucle. Dans mon programme excel j'ai des boucles de 50 lignes donc la lenteur se comprend
enfin je vois que j'ai encore beaucoup à apprendre et que c'est pas gagné même si j'arrive parfois à réaliser tout seul un code qui tourne....

merci iclic pour ta réponse
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 22h10   #5
iclic
Membre éprouvé
 
Inscription : décembre 2007
Messages : 454
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 454
Points : 497
Points : 497
Bonsoir,

A voir ton code et à vérifier
Code :
1
2
3
4
5
6
7
8
9
10
11
 
 For l = 1 To 39
 
                   MSFlexGrid1.Row = l
                   MSFlexGrid1.Col = B
                   MSFlexGrid1.CellBackColor = &HFFFF&
                   If l = 39 And B = cl Then
                         l = 0
                         B = B + 1
                   End If
  Next l
Donc si tu tombes dans la condition ' If l = 39 And B = cl Then
l = 0 ... et tu recommences ta boucle... et si celà arrive plusieurs fois,
est-ce que ça peut expliquer la lenteur,
iclic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2012, 22h31   #6
ProgElecT
Rédacteur/Modérateur
 
Avatar de ProgElecT
 
Homme Francis MILLET
Inscription : décembre 2004
Messages : 3 223
Détails du profil
Informations personnelles :
Nom : Homme Francis MILLET
Âge : 57
Localisation : France, Haute Savoie (Rhône Alpes)

Informations professionnelles :
Secteur : Communication - Médias

Informations forums :
Inscription : décembre 2004
Messages : 3 223
Points : 5 739
Points : 5 739
Envoyer un message via MSN à ProgElecT
Salut

A iclic
Select Case m And j ..... Case m = 1 And j = 1 ne provoque pas d'erreur mais ne fonctionne pas (dommage )

A dmoluc
La colorisation cellule par cellule est toujours longue, essais plutôt de paramétrer une plage de cellules.
Code :
1
2
3
4
5
'MSFlexGrid1.FillStyle = flexFillRepeat ' Proriété à faire en design
'colorisation d'une plage de celulle
MSFlexGrid1.Row = 2: MSFlexGrid1.Col = 1 'ligne et colonne de départ
MSFlexGrid1.RowSel = 4: MSFlexGrid1.ColSel = 3 'ligne et colonne de fin
MSFlexGrid1.CellBackColor = vbRed 'application de la couleur
A prendre en compte, la cellule en cour (Row,Col) affiche les couleurs encre et fond (ForeColorSel et BackColorSel), ce qui masque durant ce temps les couleurs CellBackColor et CellForeColor.
ProgElecT est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 09h49   #7
iclic
Membre éprouvé
 
Inscription : décembre 2007
Messages : 454
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 454
Points : 497
Points : 497
Bonjour,

A Progelec

Exact , mais on peut faire alors...
Code :
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
 
Dim ferie As String
 
Ferie = Trim(Str(m)) & Trim(Str(j))
 
Select Case Ferie
 
    Case "11"
      '...
    Case "51"
      '...
    Case "58"
      '...
    Case "714"
     '...
    Case "815"
      '...
    Case "111"
      '...
    Case "1111"
      '...
    Case "1225"
      '...
    Case Else
     '...
 
End Select
Et là cela fonctionne parfaitement
iclic est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2012, 10h36   #8
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
Bonjour

Merci progelec, c'est exactement ce que je cherchais à faire sans en connaitre la syntaxe, et merci aussi à iclic pour m'en avoir apris un peu plus sur les select cases. J'avais lu quelque part que les select cases n'apportaient pas grand chose par rapport aux if, alors je n'avais vraiment pas étudier la question....
C'est malheureux je suis en vacance et je n'arrive pas à m'occuper autre chose que de ce code Mes chiens vont finir par me mordre si je ne les emmènes pas un peu dans les bois
encore merci à tous les deux, j'essais de faire fonctionner le code et je vous tien au courant
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 11h07   #9
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
Code :
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
29
30
 
MSFlexGrid2.Row = 0
MSFlexGrid2.Col = A
'extraction du jour (lettre)
W = WeekdayName(Weekday(D))
'extraction de l'année, du mois et du jour (nombre)
h = Year(D): m = Month(D): J = Day(D)
'calcul du lundi de pâque
 tmpDate = fLundiPaques(h)
'si l'on est un samedi ou un dimanche je colore en jaune les entêtes et les colonnes du tableau
 
If W = "samedi" Or W = "dimanche" Then
MSFlexGrid2.CellBackColor = &HFFFF&
'j'inscrit samedi ou dimanche en entête
MSFlexGrid2.Text = Format$(W, "dd/mm/yy")
'coloriage du tableau
'colorisation d'une plage de celulle
MSFlexGrid1.Row = 0: MSFlexGrid1.Col = A 'ligne et colonne de départ
MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1: MSFlexGrid1.ColSel = A + 1  'ligne et colonne de fin
MSFlexGrid1.CellBackColor = &HFFFF&
 
'1er janvier
ElseIf m = 1 And J = 1 Then
MSFlexGrid2.CellBackColor = &HFFFF&
MSFlexGrid2.Text = Format$(D, "dd/mm/yy")
MSFlexGrid1.Row = 0: MSFlexGrid1.Col = A 'ligne et colonne de départ
MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1: MSFlexGrid1.ColSel = A + 1  'ligne et colonne de fin
MSFlexGrid1.CellBackColor = &HFFFF&
 
'etc....
Voilà un extrait du code qui fonctionne à merveille, bien sur il pourrait s'améliorré car j'utilise la même instruction pour chaque jour férié : quand je saurais faire les fonctions je reprendrais ça
Je n'ai pas encore essayé les select cases mais je vais tenter l'expérience sinon je ne m'y mettrais jamais

Merci à tous les deux

A +
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 11h28   #10
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
Encore une petite question : comment faut-il faire pour déplacer le flexgrid2 et le flexgrid1 avec la même scroolbar horizontal
j'ai supprimer celle du flexgrid 2 qui sert d'entête, alors ça serait bien qu'il soit "soudé" à celui de dessous, ci c'est possible bien sur

merci d'avance
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 17h24   #11
iclic
Membre éprouvé
 
Inscription : décembre 2007
Messages : 454
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 454
Points : 497
Points : 497
Bonjour,

Attention dmoluc

Petite modification pour l'emploi du 'select case
pour éviter les doublons (1er janvier et 11 janvier par exemple)
ferait "111" à chaque fois.
Code :
1
2
3
4
5
6
7
8
9
10
11
 
'...
ferie = Right("00" & Trim(Str(m)), 2) & Right("00" & Trim(Str(j)), 2)
Select Case ferie
 
    Case "0101"  ' 1er janvier <> 11 janvier "0111"
     '...
    Case "0501"
       '...
    Case "0508"
       '...
iclic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2012, 18h16   #12
dmoluc
Nouveau Membre du Club
 
Homme Didier
Enseignant
Inscription : juin 2012
Messages : 159
Détails du profil
Informations personnelles :
Nom : Homme Didier
Localisation : France

Informations professionnelles :
Activité : Enseignant
Secteur : Enseignement

Informations forums :
Inscription : juin 2012
Messages : 159
Points : 36
Points : 36
ok merci par contre j'ai oublié le jeudi de l’ascension et je ne sais pas comment le calculer sinon le code fonctionne impeccable, le tableau ce colore à la vitesse de la lumière
il va falloir que je regarde le code vba du programme que j'ai fait avec excel, si j'arrive à traduire ce code, mon tableau va peu être être utilisable... mais bon je pense qu'un programme créer avec vb6 posera moins de problème qu'un classeur excel en VBA car par exemple les DTPicker ne sont pas les même entre XP et windows 7, les fonctions 32 bits ne fonctionne pas en 64 bits Etc...
Alors j'espère que grace au select cases et autres petits truc je vais arrivé à créer quelque chose d'utilisable

A +
dmoluc est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 07h13.


 
 
 
 
Partenaires

Hébergement Web