Friday, October 1, 2010

Unique Variant in Lotusscript

Get unique values in a variant by calling the below function in lotusscript.

Pass the variant to Unique function.


Function Unique(vSourceArray As Variant)
Dim iFound As Integer
Dim sTargetArray() As Variant

Redim sTargetArray(0) As Variant
sTargetArray(0) = ""

Forall sText In vSourceArray
iFound = False
Forall sNewText In sTargetArray
If sText = sNewText Then
iFound = True
Exit Forall
End If
End Forall
If Not iFound Then
If sTargetArray(0) ="" Then ' First time
sTargetArray(0) = sText
Else
Redim Preserve sTargetArray(Ubound(sTargetArray)+1)
sTargetArray(Ubound(sTargetArray)) = sText
End If
End If
End Forall

Unique = sTargetArray
End Function

Search This Blog