Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Finding the non-matching values collection/array

Reply
Thread Tools

Finding the non-matching values collection/array

 
 
Robb Meade
Guest
Posts: n/a
 
      06-29-2003
Hi all,

Ok, lets say I have the following,

Request.Form collection which produces this (as the element names)

a
b
c
d
e
f

And I also have an array containg this

a
b
c

What I want to do is loop through both and response.write to the screen only
the items that are not the same, so in this case I would see

d
e
f

displayed on the screen, I've tried a couple of things but its not working,
has anyone got any suggestions...

Cheers

Robb


 
Reply With Quote
 
 
 
 
Robb Meade
Guest
Posts: n/a
 
      06-29-2003
anyone got any ideas with this? I really could do with some help please )

Robb


 
Reply With Quote
 
 
 
 
Robb Meade
Guest
Posts: n/a
 
      06-29-2003
for i = 0 to ubound(ARR2)
found = "false"
for j = 0 to ubound(ARR1)
if (ARR2(i) = ARR1(j)) then
found = "true"
exit for
end if
next
if found ="false" then
strOutput=strOutput & ARR2(i) & ","
ARR2temp = ARR2(i)
end if
next


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-29-2003
Robb Meade wrote on 29 jun 2003 in
microsoft.public.inetserver.asp.general:
> for i = 0 to ubound(ARR2)
> found = "false"
> for j = 0 to ubound(ARR1)
> if (ARR2(i) = ARR1(j)) then
> found = "true"
> exit for
> end if
> next
> if found ="false" then
> strOutput=strOutput & ARR2(i) & ","
> ARR2temp = ARR2(i)
> end if
> next



Where is ARR2temp used for ?
You need to initialise strOutput
Better use a boolean for "found"

Let me try:

strOutput=""
for i = 0 to ubound(ARR2)
found = false
for j = 0 to ubound(ARR1)
if ARR2(i) = ARR1(j) then
found = true
exit for
end if
next
if not found then
strOutput=strOutput & ARR2(i) & "<br>"
end if
next
response.write strOutput

=============================

Even so, if ARR2 has duplicates not in ARR1, they will be written
And if ARR1 has entries not in ARR2 they will not be written

Perhaps it is better to
1 delete all double entries inside each array
2 put all values in one array arr3 and
3 output all non-double entries ?

This is step 3:

for i=0 to ubound(arr3)
for j=0 to ubound(arr3)
found=false
if arr3(i)=arr3(j) and i<>j then
found=true
exit for
end if
next
if not found then
response.write arr3(i) & "<br>"
end if
next


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-29-2003
Evertjan. wrote on 29 jun 2003 in microsoft.public.inetserver.asp.general:

> for i=0 to ubound(arr3)
> for j=0 to ubound(arr3)
> found=false
> if arr3(i)=arr3(j) and i<>j then
> .....


damn, still not right, should be:

for i=0 to ubound(arr3)
found=false
for j=0 to ubound(arr3)
if arr3(i)=arr3(j) and i<>j then
found=true
exit for
end if
next
if not found then
response.write arr3(i) & "<br>"
end if
next


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
not finding a breakpoint + values are nil Dan Bensen Ruby 7 09-16-2006 03:58 AM
Is it possible to finding all return values of a C/C++ function? binjobster@gmail.com C Programming 17 08-25-2006 08:08 PM
Finding the values of Dynamic Controls in a Composite Control Bryan ASP .Net Building Controls 2 06-14-2006 08:44 PM
Finding Server... Finding Host.... enough already!!! Leesa_Tay@softhome.net Computer Support 2 01-20-2006 10:23 AM
finding every combination of n values at y positions Steve (another one) Perl Misc 4 07-05-2004 09:14 PM



Advertisments