Testing for odd or even numbers

# Thread: Testing for odd or even numbers

1. Senior Member
Join Date
Dec 1969
Posts
936

## Testing for odd or even numbers

I want to cahnge the colour of alternate rows in a table. I thought of having a count. I would then test if the number of the current row is odd or even and output a colour for each. I am not sure how to test for an odd or even number.<BR><BR>If count = odd then<BR>TableBGColour = "#333399"<BR>Else<BR>TableBGColour = "#FFFFFF"<BR>End If<BR><BR>Thanks,<BR><BR>Jamie

2. Senior Member
Join Date
Dec 1969
Posts
1,913

## You need to use Mod

If(odd Mod 2) &#062; 0 then<BR>TableBGColour = "#333399"<BR>Else<BR>TableBGColour = "#FFFFFF"<BR>End If<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
936

## RE: You need to use Mod

Thanks Eddie - that worked well!<BR><BR>Jamie

4. Member
Join Date
Dec 1969
Posts
90

## RE: Testing for odd or even numbers

Jamie,<BR>to test for an even number, divide it by 2 and compare it with its integer component, eg.:<BR> dblX=459/2<BR>if dblx=int(dblx) then <BR> fEven=true<BR>etc.<BR>Doug<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•