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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing arrays

Status
Not open for further replies.

zippynz

Programmer
May 17, 2001
50
NZ
Hi,

I have two single dimension arrays:
These are ID numbers
arrOne(0) = 12
arrOne(1) = 12
arrOne(2) = 13

These are $ Values which belong to the above ID numbers
arrTwo(0) = 20
arrTwo(1) = 30
arrTwo(2) = 40

What I need to do is search through the first array for duplicate ID numbers, when one is found I need to take the corresponding values and add them together and either replace the duplicate with one field or make a new array with all the unique values,

would be great if someone could help me out with this because im on the edge of a mental breakdown if i cant get this to go,

thanks in advcane
 
just carrying on...
so once the script has run it should turn out to be something like this

arrOne(0)=12
arrOne(1)=13

arrTwo(0)=50
arrTwo(1)=40

thanks :)
 
try this code
dim arrone(10)
arrone(0)=1
arrone(1)=2
arrone(2)=2
arrone(3)=4
arrone(4)=5
arrone(5)=6
arrone(6)=7
arrone(7)=7
arrone(8)=8
arrone(9)=15
dim i
dim j
for i=0 to 8
if arrone(i)=arrone(i+1) then
for j= i to 8
if arrone(j)=arrone(j+1) then
arrone(j)=arrone(j+1)
else
arrone(j)=arrone(j)+arrone(j+1)
end if
next
end if
next

for i= 0 to 9
Response.Write(arrone(i))
Response.Write(&quot;<br>&quot;)
next

if it is not working mail ur program to me at raghuram23@hotmail.com

with regards
raghu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top