Mettre une couleur particulière / Objet Msflexgrid

Résolu
Utilisateur anonyme - 5 févr. 2006 à 11:21
 Utilisateur anonyme - 5 févr. 2006 à 17:17
Bonjour à tous,

Je souhaiterais savoir comment je pourrais faire pour qu'une cellule d'un objet msflexgrid soit coloré en rouge si la condition est fausse et en vert si c'est vrai.

<===============>
For i = 1 to fin
For j = 1 to fin
If machin( i, j) = false then
colorer Tms( i, j) en rouge
else
colorer Tms( i, j) en vert
end if
Next J
Next i
<===============>

(Il est où le bouton pour ajouter du code!? Désolé...1er post)

Merci de votre aide

2 réponses

Slyders Messages postés 300 Date d'inscription mardi 12 octobre 2004 Statut Membre Dernière intervention 8 janvier 2010 2
5 févr. 2006 à 15:32
----------------------------------------
If machin( i, j) = True Then
Tms.Col = i
Tms.Row = j
Tms.CellBackColor = vbGreen
ElseIf machin( i, j) = False Then
Tms.Col = i
Tms.Row = j
Tms.CellBackColor = vbRed
End If
----------------------------------------

J'espère que sa pourra t'aider ^^
3
Utilisateur anonyme
5 févr. 2006 à 17:17
Je savais pas qu'on pouvait mettre "vbred" !! Merci! Moi, j'avais comme ca:

Function mort_ou_vie(a As Integer, b As Integer, ms1 As MSFlexGrid, Tvi() As Boolean)
For a = 1 To Longmax
For b = 1 To Longmax

If Tvi(a, b) = False Then
ms1.Col = a - 1
ms1.Row = b - 1
ms1.CellBackColor = QBColor(4)

Else
ms1.Col = a - 1
ms1.Row = b - 1
ms1.CellBackColor = QBColor(10)

End If
Next b
Next a
End Function
3
Rejoignez-nous