Array problem

1. Member
Join Date
Dec 1969
Posts
37

## 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&#039;d appreciate any help!<BR><BR>Thanks in advance!<BR><BR>CODE<BR>&#060;%<BR>&#039;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> &#039;goes through each course which is taken<BR> For y = LBound(takenArray, 2) To UBound(takenArray, 2)<BR> &#039;compares courses that should be taken to ourses actually taken<BR> &#039;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> &#039;if the array is empty, the course hasn&#039;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>%&#062;<BR><BR>&#060;%<BR>&#039;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>&#039;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>%&#062;<BR>RESULT<BR>Number of elements: 4<BR>0: <BR>1: <BR>2: <BR>3: 43434

2. Senior Member
Join Date
Dec 1969
Posts
3,195

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>

3. Member
Join Date
Dec 1969
Posts
37

## 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&#039;d appreciated it

4. Senior Member
Join Date
Dec 1969
Posts
3,195

## RE: I have to ask

Ok so where do you initialize the variable "t"?<BR><BR>t=0 &#060;----??????<BR><BR>You could put in a couple of response.write&#039;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>

5. Senior Member
Join Date
Dec 1969
Posts
3,195

## 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>

6. Member
Join Date
Dec 1969
Posts
37

## 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
•