
Array problem
My code is all working smoothly, until the final array..array4.<BR>The number of elements print out correctly, but the first three elements appear balnk.<BR>i anyone can see a reason for this i'd appreciate any help!<BR><BR>Thanks in advance!<BR><BR>CODE<BR><%<BR>'goes through each course that should be taken<BR>For x = LBound(arrArray, 2) To UBound(arrArray, 2)<BR> Dim i<BR> i=0<BR> mycount = 0<BR> 'goes through each course which is taken<BR> For y = LBound(takenArray, 2) To UBound(takenArray, 2)<BR> 'compares courses that should be taken to ourses actually taken<BR> 'if a course is taken, added to an array<BR> If arrArray(2, x) = takenArray(0, y) Then<BR> ReDim array3(i)<BR> array3(i) = takenArray(0, y)<BR> i=i+1<BR> mycount = UBound(array3)+1<BR> End If<BR> Next<BR> 'if the array is empty, the course hasn't been taken so added to another array<BR> If mycount = 0 Then<BR> ReDim array4(t)<BR> array4(t) = arrArray(2, x) <BR> t=t+1<BR> end if <BR><BR>Next<BR>%><BR><BR><%<BR>'Pr ints number of elements ie. number of courses not taken<BR>Response.Write "Number of elements: "& UBound(array4)+1<BR>Response.Write "<BR>"<BR>'goes through each course which should be taken but are not and prints them out<BR>For x= LBound(array4) To Ubound(array4)<BR>Response.Write x&": "&array4(x)<BR>Response.Write "<BR>"<BR>Next <BR>%><BR>RESULT<BR>Number of elements: 4<BR>0: <BR>1: <BR>2: <BR>3: 43434

I have to ask
Is this stuff in a database? If yes, why not just use SQL to figure out the courses taken/not taken, etc.? ; )<BR><BR><BR><BR>

RE: I have to ask
yes this is stuff taken from a large number of tables in a database. <BR>I have placed the information from the resultset into the arrays shown as i feel they are easier to manipulate.<BR>they are all working perfectly apart from array4.<BR>if you can help me with why this is, i'd appreciated it

RE: I have to ask
Ok so where do you initialize the variable "t"?<BR><BR>t=0 <??????<BR><BR>You could put in a couple of response.write's to help you debug. ; )<BR><BR>If mycount = 0 Then <BR> ReDim array4(t) <BR> array4(t) = arrArray(2, x) <BR> response.write "The current value of t = "&t<BR> response.write "The current course not taken: "&arrArray(2,x)<BR> t=t+1 <BR>else<BR> response.write "The current value of t = "&t<BR>end if <BR><BR>Lastly, there is no need to use LBOUND() function. Your arrays will always start at 0.<BR><BR> For x = 0 To UBound(arrArray, 2) <BR><BR>You have to debug your values, no other way around it. ; )<BR><BR>Good luck<BR>Pete<BR><BR><BR>

As an aside, you really think it
is easier to loop thru multiple arrays for EACH record than writing some good SQL?!<BR><BR>select somecoursefield as coursenottaken<BR> from sometable<BR> where somecourse NOT IN (select someothercoursefield<BR> from someothertable)<BR><BR>What is not difficult about that? ; )<BR>

Thanks for your help pete
Thanks for your advice pete.<BR>perhaps I should reconsider my way of thing.<BR>Thanks again
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

