# 3 listbox row colours?

Hi,
I have the following line of code which is responsible for alternating the rows of a listbox:

```if row mod 2 <> 0 then ```

Can someone math oriented tell me how to have 3 colours alternating?
For example:
Row 1 RED
Row 2 WHITE
Row 3 BLUE

Thanks.

[quote=132093:@Richard Summers]Hi,
I have the following line of code which is responsible for alternating the rows of a listbox:

```if row mod 2 <> 0 then ```

Can someone math oriented tell me how to have 3 colours alternating?
For example:
Row 1 RED
Row 2 WHITE
Row 3 BLUE

Thanks.[/quote]

Use a for next.

You cannot use mod, because some numbers can be divided both by 2 and 3.

Still no idea how to do that?
The middle line of code has me stumped?

For i As Integer = 0 to ListBox1.Listcount -1
Please make my listbox rows red white and blue - thank you Mr computer
Next i

In CellBackground paint:

[code]Select case row Mod 3
Case 0
g.forecolor = &cFF000000
Case 1
g.forecolor = &cFFFFFF00
Case 2
g.forecolor = &c0000FF00
End Select

g.fillrect 0,0, g.Width, g.Height[/code]

That worked perfectly (although it nearly blinded me)
Thank you both for the quick responses

Karen: nice trick.

Richard: what is the use ?

Why do I ask that question ?
I use a two colours background for the user: (s)he will follow a line easilly. Yes, lines (I like dotted lines) do the same trick, but is is nicer with background colors. I also add a grey background colour (1 line with the background grey, the next one without) at print (print to pdf) time too.

BUT: I use a magenta background (so a third colour) on condition in one project: the customer account is active, when I display the whole set of customers. I have another window that displays only the active customers and it use a two colours Row background.
I may also use that magenta background for say inventory of this part number is 0 (for example).

Richard is very patriotic : Red, White, and Blue

God Save the Queen !

[quote=132232:@Michel Bujardet]Richard is very patriotic : Red, White, and Blue

God Save the Queen ![/quote]

Excuse me… it’s a King we have nowadays…

God Save the King!

Emile, it was a proof of concept question, and will not be used in any of my apps.
Just curious, for future reference.

Nice

I implement it to see what can be the result and yes, it is nice. I came back to two colours 'cause I love it !