Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loops

Status
Not open for further replies.

PeteHotchkiss

Programmer
Mar 20, 2002
1
GB
i'm going loopy !
I've got two arrays arrDevs() and myArray().

arrDevs is a 2 dimensional array ..
[1, Name1]
[2, Name2]
[3, Name3]
etc ...

myArray is a 1 dimensional array

[1,2,3,4,5,6,7,8]

I would like to loop through myArray() replacing the numbers with the appropriate 'Name'

ie,
[Name1, Name2, Name3 etc...]

I have the following...

code:------------------------------------------------------------
<% dim matchVal
for i=0 to Ubound(myArray)
Response.write(&quot;myArray loop: &quot; & i & &quot; value &quot; & myArray(i) & &quot;
&quot;)
for j=0 to topLimit
matchVal = myArray(i)
Response.write(&quot; &quot;)
Response.write(&quot;j loop: &quot; & j & &quot; value <b>&quot; & arrDevs(0,j) & &quot; </b>myArray(i)=&quot; & matchVal & &quot;
&quot;)
IF arrDevs(0,j) = myArray(i) THEN
Response.write(&quot;name:&quot; & arrDevs(1,matchVal-1) & &quot;
&quot;)
END IF
next
Response.write(&quot;
&quot;)
next
%>


this doesnt seem to work though. It seems that the IF statement is not evaluating myArray(i) to find a match ... any clues as to where I might be going wrong here ?
 
Your topLimit variable doesn't seem to be defined anywhere or else you are not showing us that part of the code.

Dim i,j
for i = 0 to UBound(myArray)
for j = 0 to UBound(arrDevs, 2)
if myArray(i) = arrDevs(0,j) then
Response.Write myArray(i) & &quot;: &quot; & arrDevs(0,j) & &quot;<BR>&quot;
end if
next
next

That should print out all matching records.

Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top