&nbsp;<BR>My attempt at a random ad generator -- GIVEN SOME DIFFICULT SITUATIONS: Admin can pick 3 of up to 16 adds to display by setting value to 0. If only two show 0, then the other fourteen will rotate -- if there are 14, maybe there are only four. Or maybe nothing is zero so all rotate, etc.<BR><BR>This is my approach which almost works, but sometimes everything comes up empty.<BR><BR>What is the best solution to this?<BR><BR> <BR>if (count0 &#060; 3) <BR>{<BR>foreach(Brick txtBrickMember1 in promoBricks1.PageBrick.Blocks[0].FindBricks(Brick.TypeText)) <BR>{ <BR> //Break if difference is reached <BR> if (count1 == (getThisManyMore + addAnotherLoop)) <BR> break; <BR> <BR> //Array of Bricks to Avoid<BR> int Total = (16 - count0); if (x &#060; (16 - Total)) <BR> {<BR> string[] avoidBricks = avoidPromoBricks.Split(&#039;/&#039;);<BR><BR> avoidThisBrick = Convert.ToInt32(avoidBricks[x]);<BR> x++; <BR>} <BR>pickRandomBrick = rand.Next(1,6);<BR><BR>if (pickRandomBrick == avoidThisBrick)<BR>{ <BR>pickRandomBrick = rand.Next(1,6);<BR>}<BR><BR> if (promoBricks1.Title == previousTitle)<BR> { <BR> pickRandomBrick = rand.Next(1,6);<BR> }<BR><BR><BR> <BR> //if (promoBricks1.Title == "Promo" + pickRandomBrick)<BR> if (promoBricks1.Title == "Promo" + pickRandomBrick && promoBricks1.Title != previousTitle)<BR> { <BR> TextBrick mainPromoText1 = txtBrickMember1 as TextBrick;<BR> if (mainPromoText1 != null) <BR> { <BR> //Quit Loop if ~Rotate = 0<BR> if (mainPromoText1.Body == Convert.ToString(0)) <BR> break; <BR> if (mainPromoText1.Title != "~Rotate") <BR> <BR>{ <BR> count1++; //Count Text Bricks for ~Rotate = 1<BR> <BR> previousTitle = mainPromoText1.Title;<BR> string title = (mainPromoText1.Title);<BR> string body = (mainPromoText1.Body);<BR> output.WriteStartElement("RotateTextBrick");<BR> output.WriteAttributeString("Title", title);<BR> output.WriteAttributeString("Body", body); output.WriteEndElement(); <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR>