
12/08/2006, 07:36
|
| | Fecha de Ingreso: abril-2004
Mensajes: 192
Antigüedad: 20 años, 11 meses Puntos: 0 | |
Hola te paso un ejemplo:
Código:
Dim Arreglo() As String
Dim TempArray() As String
Private Sub Command1_Click()
Dim x As Integer, x2 As Integer, y As Integer
Dim z As Integer, Elemento As Variant
List1.Clear
ReDim Arreglo(6)
Arreglo(0) = "1"
Arreglo(1) = "2"
Arreglo(2) = "3"
Arreglo(3) = "3"
Arreglo(4) = "3"
Arreglo(5) = "2"
Arreglo(6) = "1"
For i = LBound(Arreglo) To UBound(Arreglo)
ReDim Preserve TempArray(i)
TempArray(i) = Arreglo(i)
Next
For x = 0 To UBound(Arreglo)
z = 0
For y = 0 To UBound(Arreglo)
If Arreglo(x) = TempArray(z) And y <> x Then
Arreglo(y) = ""
Nduplicado = Nduplicado + 1
End If
z = z + 1
Next y
Next x
For Each Elemento In Arreglo
If Elemento <> "" Then List1.AddItem Elemento
Next
MsgBox "Elementos duplicados: " & Nduplicado, vbInformation
End Sub
------------------ |