1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim strText As String
strText = "test"
For i = 0 To 10
MSHFlexGrid1.AddItem strText
Next i
End Sub
Private Sub Command2_Click()
Dim Un As New Collection
Dim Tableau() As Integer
Dim x As Integer
Dim i As Integer
For i = 0 To MSHFlexGrid1.Rows - 1
On Error Resume Next
'Création d'une collection de données uniques (sans doublons)
Un.Add i, MSHFlexGrid1.TextMatrix(i, 0)
'Une erreur survient si l'élément existe dans la collection.
'La procédure enregistre le numéro de ligne correspondant dans un tableau.
If Err.Number <> 0 Then
x = x + 1
ReDim Preserve Tableau(1 To x)
Tableau(x) = i
End If
On Error GoTo 0
Next i
'On sort si aucun doublon n'a été trouvé.
If x = 0 Then Exit Sub
MSHFlexGrid1.Redraw = False
For x = UBound(Tableau) To LBound(Tableau) Step -1
MSHFlexGrid1.RemoveItem (Tableau(x))
Next x
MSHFlexGrid1.Redraw = True
End Sub |
Partager