About This Code
Brief Description:
LS version of @Unique
Contributor:
Chris Crites
Last Modified:
10 Dec 2002
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Here is a small LotusScript function for returning an array of unique values from the array passed to the function.
Function unique(vList As Variant) As Variant
Dim aList
Dim aList2
Dim answer() As Variant
aList = vList
aList2 = vList
For n = Lbound(aList) To Ubound(aList)
Redim Preserve answer(n)
answer(Arraygetindex(aList, aList2(n))) = aList(n)
If Isempty(answer(n)) Then answer(n) = ""
Next
unique = Fulltrim(answer)
End Function
Usage / Example
Comments
Posted by Roche Olivier on 02/03/2003 01:41:29 AMoption declare
if option declare is on "n" needs to be defined :-)
i made it a double for more that integer values.
thus:
Function unique(vList As Variant) As Variant
Dim aList
Dim aList2
Dim answer() As Variant
aList = vList
aList2 = vList
Dim n As Double
For n = Lbound(aList) To Ubound(aList)
Redim Preserve answer(n)
answer(Arraygetindex(aList, aList2(n))) = aList(n)
If Isempty(answer(n)) Then answer(n) = ""
Next
unique = Fulltrim(answer)
End Function
Posted by Roche Olivier on 02/05/2003 02:27:53 AMoooops
Posted by Roche Olivier on 07/03/2003 09:10:56 AMoooops
make the "n" an integer , otherwise it crashes notes completely, the client, sorry for the wrong
posting.
here is the one i am using now , and it works without a problem , ..nice piece of code to use,
thanx..
Function unique(vList As Variant) As Variant
Dim aList
Dim aList2
Dim answer() As Variant
aList = vList
aList2 = vList
Dim n As Integer
For n = Lbound(aList) To Ubound(aList)
Redim Preserve answer(n)
answer(Arraygetindex(aList, aList2(n))) = aList(n)
If Isempty(answer(n)) Then answer(n) = ""
Next
unique = Fulltrim(answer)
End Function