Author : Dhaval Amin
Date Submitted : 5/18/2007
Category : String Handling/Manipulation
Compatibility : VB 6,VB 5
This code has been accessed 4803 times.
Task : 'Return the distinct element from string array
Declarations
Code
'initially array is blank
arrayblank = True
'start check form element 0
For x = 0 To 9
'when start check from next element counter = 0
elementCounter = 0
For y = x To 9
If s1(x) = s1(y) Then
'if found same value, counter increase
elementCounter = elementCounter + 1
End If
Next y
If arrayblank = True Then
arrayblank = False
s2(0) = s1(x)
Else
For z = LBound(s2) To UBound(s2)
'tmp = Split(s2(w), ",")
If s2(z) = s1(x) Then
Found = True
Exit For
Else
Found = False
End If
Next z
If Found = False Then
ReDim Preserve s2(UBound(s2) + 1)
s2(UBound(s2)) = s1(x) '& "," & z
End If
End If
Next x
'Display unique array with counter
For x = LBound(s2) To UBound(s2)
Debug.Print s2(x)
Next x