Indefinite Loop Prob

1. Senior Member
Join Date
Dec 1969
Posts
583

## Indefinite Loop Prob

Maybe I am just being stupid, but I cant seem to find out the reason why this code cant get out of a loop thats in it: heres the code:<BR><BR>&#060;%<BR> Dim iYearLoopCount<BR> Dim inc1, inc2, inc3, inc4, incCOUNT, iYearCount, iYear, bStopLoop<BR> Dim DayStart, DayEnd, sGetMonth, iIncrement<BR> <BR> sGetMonth = Request("month")<BR> iYear = Request("year")<BR> <BR> <BR> SELECT CASE sGetMonth<BR> <BR> CASE "January"<BR> &#039;January 2000<BR> DayStart = 7<BR> DayEnd = 2<BR> aINCS = Array(2,1,1,1)<BR> <BR> CASE "Febuary"<BR> &#039;Febuary 2000<BR> DayStart = 3<BR> DayEnd = 3<BR> aINCS = Array(2,1,1,1)<BR> <BR> CASE "March"<BR> &#039;March 2000<BR> DayStart = 4<BR> DayEnd = 6<BR> aINCS = Array(1,1,1,2)<BR> <BR> End SELECT<BR> <BR> iYearCount = 1999<BR> iYearLoopCount = 0<BR> bStopLoop = False<BR> <BR> Do While Not bStopLoop<BR> iYearCount = iYearCount + 1<BR> iYearLoopCount = iYearLoopCount + 1<BR> incCOUNT = 0<BR> <BR> For Each iIncrement In aINCS<BR> incCOUNT = incCOUNT + 1<BR> <BR> SELECT CASE incCOUNT<BR> Case 1<BR> inc1 = iIncrement<BR> Case 2<BR> inc2 = iIncrement<BR> Case 3<BR> inc3 = iIncrement<BR> Case 4 <BR> inc4 = iIncrement <BR> End SELECT<BR> <BR> Next<BR> <BR> SELECT CASE iYearLoopCount<BR> <BR> Case 1<BR> DayStart = DayStart + inc1<BR> DayEnd = DayEnd + inc1<BR> Case 2<BR> DayStart = DayStart + inc2<BR> DayEnd = DayEnd + inc2<BR> Case 3<BR> DayStart = DayStart + inc3<BR> DayEnd = DayEnd + inc3<BR> Case 4<BR> DayStart = DayStart + inc4<BR> DayEnd = DayEnd + inc4<BR> <BR> End SELECT <BR> <BR> If (iYearLoopCount = 4) And Not (iYear = iYearCount) Then<BR> iYearLoopCount = 1 <BR> End If <BR> <BR> If iYearCount = iYear Then<BR> bStopLoop = True<BR> End If <BR> <BR> Loop<BR> <BR>%&#062;<BR><BR>Month: &#060;%=sGetMonth%&#062;<BR><BR>Year: &#060;%=iYear%&#062;<BR><BR><BR>Start Day: &#060;%=DayStart%&#062;<BR><BR>End Day: &#060;%=DayEnd%&#062;<BR><BR>Help me please :)<BR><BR>Thanks

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

## I think it is because

you are comparing string to integer. Try This:<BR><BR>If Cint(iYearCount) = Cint(iYear) Then<BR>bStopLoop = True<BR>End If <BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
6,476

## RE: Indefinite Loop Prob

I think peek is correct on that one...<BR><BR>Add some debug...<BR><BR>Where you start your loop.<BR><BR>intAllStop = 0<BR>Do While Not bStopLoop <BR>intAllStop = intAllStop + 1<BR><BR>IF intAllStop = 10 Then<BR>Exit Do<BR>End IF<BR><BR>This will alow you to control how many loops are done so you dont go infinate...<BR><BR>Now you can write out all the variables so you can see what data your working with...<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## Also

year(date)<BR><BR>returns 2003 not 03 or 3

#### Posting Permissions

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