473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Finding the non-matching values collection/array

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
Jul 19 '05 #1
4 3752
anyone got any ideas with this? I really could do with some help please :o)

Robb
Jul 19 '05 #2
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
Jul 19 '05 #3
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)
Jul 19 '05 #4
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)
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: m sergei | last post by:
I am not asking for code but wanted help with understanding the algorithm to permute all characters of a string. say string is "ABCD" I want to know the algorithm for finding all permutations of...
2
by: Paweł | last post by:
Hello! I'm looking for efficient code or site where I can find code for finding one string in another string. String which I search should have "wild" characters like '?' for any one char and...
32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
9
by: minil | last post by:
Hi any c function in linux to return size of directory (Including its files & subdirectories & its files).. I can stat() only files . not for directories. please reply me soon Thanks in...
2
by: marc.gibian | last post by:
I am modifying an existing ASP.NET application to make it SSL compatible. I have already searched the codebase and eliminated all hardcoded "http" instances, replacing them with a method call that...
4
by: spivee | last post by:
I'm having an odd type of issue. I want to be able to pass an element name in my javascript event and find the location of the element, be it a div, span, img whatever, specifically the top and...
4
by: sathyashrayan | last post by:
(This is not a home work question) Dear group, I want a program to find one number between a set of natural number.A program to guess a number in between a Natural number set.This should be a...
12
by: bg_ie | last post by:
Hi, I'm updating my program to Python 2.5, but I keep running into encoding problems. I have no ecodings defined at the start of any of my scripts. What I'd like to do is scan a directory and...
0
NeoPa
by: NeoPa | last post by:
Introduction: This seems like a very straightforward topic. Why would anyone need help finding MS Access Help related to this topic? I can't really answer that except to say that I know from...
7
by: Nick | last post by:
Hi there, I have a website that functions fine locally, but when published to the server it develops a bottleneck during loading some of the pages. Basically what happens is the page loads to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.