Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

difference in arrays

Posted on 2006-06-04
3
Medium Priority
?
228 Views
Last Modified: 2013-12-18
Hi all,

I picked up this function from the internet and I am trying to modify it to do the following:
I have the following fields on the form:

testdate1 = multivalued date fields which has all the testdates for the period
testdate2 = testdate1, computed to itself and set to the value of 1 if null(testdate1 which will never change), with this field, I am always trying to keep a complete list of testdate1 in case some test dates gets deleted from it. This way also using the next function we will be able to erase all dates which are the same in testdate1 and testdate2 and keep the reminder which are those dates that got deleted at some stage of testdate1
resultdate = list of those deleted dates from testdate1 and are found in testdate2

Here's the function and I'll place the sentence "my modifications" next to those lines that I am modifying. Could you pls help me clarify if this will work. I have attempted to get it to work and it didn't so maybe I am setting wrong variables


Function DifferentArrayItems (a1 As Variant, a2 As Variant) As Variant
'** return an array that has all the elements in array a1
'** array a2 that are different

my modifications

a1 = doc.testdate1(0)
a2 = doc.testdate2(0)



On Error Goto processError
Dim returnArray As Variant
Dim tempList List As Variant
Dim count As Integer


my modifications
returnarray = doc.resultdate(0)

'** convert a2 into a list, for easier searching
If Isscalar(a2) Then
tempList(a2) = a2
Else
Forall stuff In a2
tempList(stuff) = stuff
count = count + 1
End Forall
End If
'** initialize the return array
Redim returnArray(0 To count)
'** check all the elements in a1 against the new list we made
count = 0
If Isscalar(a1) Then
If Iselement(tempList(a1)) Then
Erase tempList(a1)
Else
returnArray(count) = a1
count = count + 1
End If
Else
Forall element In a1
If Iselement(tempList(element)) Then
Erase tempList(element)
Else
returnArray(count) = element
count = count + 1
End If
'** make sure we have room in the returnArray
If (count = Ubound(returnArray)) Then
Redim Preserve returnArray(0 To count + 50)
End If
End Forall
End If
'** now add anything that's still left in tempList, which will be
'** things in a2 that weren't in a1
Forall leftover In tempList
'** Listtag always returns a String, so we want to use the
'** list element instead
'returnArray(count) = Listtag(leftover)
returnArray(count) = leftover
count = count + 1
'** make sure we have room in the returnArray
If (count = Ubound(returnArray)) Then
Redim Preserve returnArray(0 To count + 50)
End If
End Forall
'** resize the return array down, so it will have the right
'** number of elements
If (count = 0) Then
Erase returnArray
Else
Redim Preserve returnArray(0 To count - 1)
End If
'** give the returnArray back to the user
DifferentArrayItems = returnArray
Exit Function
processError:
Print "Error " & Err & ": " & Error$
Redim returnArray(0)
Erase returnArray

my modifications, redim array, otherwise, i get the using uninitialized dynamic array error

Redim Preserve returnArray(0 To count + 50)

DifferentArrayItems = returnArray
Exit Function
End Function


Thank you in advance

0
Comment
Question by:varvoura
  • 2
3 Comments
 

Author Comment

by:varvoura
ID: 16827128
one more modification

If I declare a third array a3 as variant, could I then set the value of differentarrayitems to that array at the end

for example,

DifferentArrayItems = returnArray
dim d3 as variant
d3 = doc.resultdate(0)
d3 = differentarrayitems
Exit Function
End Function



0
 
LVL 63

Accepted Solution

by:
SysExpert earned 750 total points
ID: 16827176
With no  connection to the actual formulas, I would suggest that you make sure that you never hit the 32 K limit of the field holding the old test dates ( history ).

Yo may need to archive yearly and recreate depending on testing frequency.

I hope this helps !

0
 

Author Comment

by:varvoura
ID: 16827238

Thanks for your advise, I'll keep that in mind.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question