473,402 Members | 2,064 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,402 software developers and data experts.

Return an Array that contains only the diffrent items from 2 arrays

Erv
<%
' Return item that are NOT duplicated in either array
function ShowDiff(array1, array2)
dim d, item, thekeys, build_arr

' Build Array - a command that will be Execute
build_arr = "anArray = ARRAY("

' Loop through the first array, add to output
for x = lbound(array1) to ubound(array1)
build_arr = build_arr & "array1(" & x & "), "
next

' Loop through the second array, add to output
for y = lbound(array2) to ubound(array2)
build_arr = build_arr & "array2(" & y & "), "
next

' Cleanup last comma
build_arr = left(build_arr, len(build_arr) - 2)
build_arr = build_arr & " )"

' Excute the build statement
execute build_arr
' Show differences
set d = CreateObject("Scripting.Dictionary")
d.removeall
d.CompareMode = 0
for each item in anArray
if not d.Exists(item) then
d.Add item, item
else
d.Remove item
end if
next
thekeys = d.keys
set d = nothing
ShowDiff = thekeys
end function
%>

Apr 26 '07 #1
1 1167
Erv wrote:
<%
' Return item that are NOT duplicated in either array
function ShowDiff(array1, array2)
dim d, item, thekeys, build_arr

' Build Array - a command that will be Execute
build_arr = "anArray = ARRAY("
You expect us to embrace a script that uses Execute to execute a
string???
Give it some thought. I'm sure you can come up with a way to avoid
Execute.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Apr 26 '07 #2

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

Similar topics

2
by: Steve | last post by:
I'm working on an e-commerce site, and one of the things I need to do is split an existing order into two orders. The problem I'm having is not creating the new order, but getting the remaining...
11
by: Stefan Richter | last post by:
Hi, I want to create an associative Array with a PHP variable (article ID) as Key and another associative array as it's value. How do I instanciate it, how can I fill it? I want something...
2
by: Asad Khan | last post by:
Hello, I am writing a method that returns an array as an Object. Initially there is a single dimension array Object X. However, I can insert other arrays as Objects in X, thus I can end up with...
2
by: Louis | last post by:
What I am trying to do seems simple, but I haven't figured out how to do it. I need to add the contents of the cells in one array, subject to the values in another array. Normally I would utilize...
4
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving...
6
by: Yanhao Zhu | last post by:
Hi, all, If I have an array like int m = new int { 0, 1, 2, 3 }, is there a way I can separate the array into two, like int m01 = somefunction?(m,0,2) // m01 will hold 1st and 2nd items in...
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
2
by: MrL8Knight | last post by:
I am building a simple shopping cart and I am having problems trying to add the costs of the items to generate a total cost. I am new at this so forgive me if my technical verbiage isn’t the...
27
by: aravind | last post by:
Hi, I need to develop a menu system for a project of mine. The menu will be displayed on a character LCD display driven by ARM7 Microcontroller. For this purpose i wish to construct a structure in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.