Comparing Elements in two seperate array's...

# Thread: Comparing Elements in two seperate array's...

1. Senior Member
Join Date
Dec 1969
Posts
719

## Comparing Elements in two seperate array's...

I have two arrays one containing a list of check box values entitled (aryQ2) and the other containing a list of text box values entitled (aryQ2Rank)...<BR><BR>What I need to do is ensure that when a check box contains a value the cooresponding text box contains a value as well...<BR><BR>Here&#039;s what I thought would work but it doesn&#039;t...<BR><BR>aryQ2 = Split(Request.Form("chkQ2"), ",")<BR>aryQ2Rank = Split(Request.Form("txtQ2Rank"), ",")<BR>For x = 0 To UBound(aryQ2)<BR> For r = x To UBound(aryQ2Rank)<BR> If aryQ2(x) &#060;&#062; "" _<BR> And aryQ2Rank(r) = "" Then<BR> &#039; do something<BR> End If<BR> Next<BR>Next<BR><BR>Can someone shed some light on this...

2. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## How do the 2 arrays..

.. associate to each other?

3. Senior Member
Join Date
Dec 1969
Posts
719

## RE: How do the 2 arrays..

whatta ya mean..?

4. Senior Member
Join Date
Dec 1969
Posts
107

## take out the internal loop...

Make sure the arrays are the same size and just loop though<BR>once testing for blanks

5. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## RE: How do the 2 arrays..

In the first array, how do you know it has a corresponding item in array 2?

6. Senior Member
Join Date
Dec 1969
Posts
719

## RE: take out the internal loop...

whatta ya mean...<BR><BR>can ya show me an example...<BR>

7. Senior Member
Join Date
Dec 1969
Posts
2,930

## do

loop I <BR> if (len(checkboxarray(I) &#062; 0) Then<BR> if (len(textboxarray(I)) = 0) Then <BR> &#039;error<BR> else<BR> &#039;no error<BR> end if<BR> end if<BR>next

8. Senior Member
Join Date
Dec 1969
Posts
719

## RE: How do the 2 arrays..

All items (Check Boxes) in the first array will have cooresponding items (Text Boxes) in the second...<BR><BR>Because on the screen for each check box there is a text box next to it...

9. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## But, the arrays MIGHT NOT be the ...

.. same size.<BR><BR>A checkbox passes NO value if it isn&#039;t checked.<BR><BR>So, if there are 10 items and only 5 are checked. He will end up with an checkbox array that has an UBound of 4. He will have an array of textboxes that has an UBound of 9.

10. God
Senior Member
Join Date
Dec 1969
Posts
18,177