Private Sub Command1_Click()
Dim a() As Integer, i, j, n As Integer
n = 100
ReDim a(n)
Randomize
Print "原始数祖:(个数=" & n & ")"
For i = 1 To 100
a(i) = Int(Rnd * 100)
Print a(i);
If i Mod 20 = 0 Then Print
Next
For i = 2 To n
For j = 1 To i - 1
If a(i) = a(j) Then Exit For
Next
If j < i Then
For j = i To n - 1
a(j) = a(j + 1)
Next
n = n - 1
End If
Next
ReDim Preserve a(n)
Print vbCrLf & "去除重复后数组:(个数=" & n & ")"
For i = 1 To n
Print a(i);
If i Mod 10 = 0 Then Print
Next
End Sub
Private Sub Command1_Click()
Dim a()
a = Array("a", "c", "d", "b", "c", "b", "c", "a")
Call FilterArry(a)
For i = 0 To UBound(a)
Print a(i)
Next
End Sub
Sub FilterArry(a())
Dim i As Integer, j As Integer, l As Integer
l = -1
Dim b As Variant
b = a
For i = 0 To UBound(b)
For j = 0 To i - 1
If b(i) = b(j) Then Exit For
Next
If j = i Then
l = l + 1
a(l) = b(i)
End If
Next
ReDim Preserve a(l)
End Sub