Remove non-consecutive duplicates from combobox
Remove non-consecutive duplicates from combobox
(OP)
i know how to remove duplicates from consecutive list in a combobox.
rent
rent
rent
count
count
How do you remove duplicates that are not consecutive?
rent
count
rent
rent
count
count
the above code only removes the two consecutive values
leaving
rent
count
rent
count
I want it to leave
rent
count
rent
rent
rent
count
count
CODE
Dim varI As Integer
Dim strTemp As String
Do While varI <= cmbCategory.ListCount
If varI = cmbCategory.ListCount Then
Exit Sub
End If
If strTemp = cmbCategory.List(varI) Then
cmbCategory.RemoveItem (varI)
intK = intK + 1
Else
strTemp = cmbCategory.List(varI)
varI = varI + 1
End If
Loop
Dim strTemp As String
Do While varI <= cmbCategory.ListCount
If varI = cmbCategory.ListCount Then
Exit Sub
End If
If strTemp = cmbCategory.List(varI) Then
cmbCategory.RemoveItem (varI)
intK = intK + 1
Else
strTemp = cmbCategory.List(varI)
varI = varI + 1
End If
Loop
How do you remove duplicates that are not consecutive?
rent
count
rent
rent
count
count
the above code only removes the two consecutive values
leaving
rent
count
rent
count
I want it to leave
rent
count
RE: Remove non-consecutive duplicates from combobox
RE: Remove non-consecutive duplicates from combobox
File is about 195000 lines long and one column
from the file is used to fill combo box
RE: Remove non-consecutive duplicates from combobox
RE: Remove non-consecutive duplicates from combobox
What is a SELECT DISTINCT? and how does it work? Form what I read it is not going to help me in doing the.
RE: Remove non-consecutive duplicates from combobox
RE: Remove non-consecutive duplicates from combobox
CODE
On Error Resume Next
Dim blnError As Boolean
blnError = True
blnArrayFilled = False
varFileNum = FreeFile 'set as freefile so that program can set any file open as num
start_time = Timer
'Set a filter for opening files to open specific files only
dlgMain.Filter = "Text Files(*.CSV)|*.csv|"
'Data Files(*.DTA)|*.dta|Text Files (*.TXT)|*.txt"
dlgMain.ShowOpen 'show file open dialog box
If dlgMain.filename <> "" Then
Open dlgMain.filename For Input As varFileNum
If blnError <> False Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(dlgMain.filename)
Set a = f.OpenAsTextStream(1)
'count the number of lines in the text file
Do While a.AtEndOfStream <> True
''place a line into a variable
retstring = a.ReadLine
''count that line
intI = intI + 1
Loop
''count the number of commas
''PROBLEM: Skips consecutive commas therefore is two down on number of columns
Call CountColumns
'reset the text stream
Set a = f.OpenAsTextStream(1)
'redefine the array
ReDim TempArray(intI - 1, intColumnCount + 2)
''loop through the text file one line at a time and place into the array
I = 0
Do While a.AtEndOfStream <> True
retstring = a.ReadLine
varText = Split(retstring, ",")
For J = 0 To intColumnCount + 2
varText = Split(retstring, ",")
TempArray(I, J) = varText(J)
Next J
''fills the combo box here
cmbPropType.AddItem TempArray(I, 9)
I = I + 1
Loop
MsgBox ("Sucess")
Else
Close #varFileNum
Exit Sub
End If
End If
dlgMain.filename = ""
blnArrayFilled = True
Close #varFileNum
stop_time = Timer
lblInput.Caption = Format$(stop_time - start_time, _
"0.00") & " sec"
End Sub
RE: Remove non-consecutive duplicates from combobox
CODE
retstring = a.ReadLine
varText = Split(retstring, ",")
For J = 0 To intColumnCount + 2
varText = Split(retstring, ",")
TempArray(I, J) = varText(J)
Next J
''fills the combo box here
IsLoaded = False
For J = 0 To cmbPropType.ListCount - 1
If (cmbPropType.Column(0, J) = TempArray(I, 9)) Then
IsLoaded = True
Exit For
End If
If (IsLoaded = False) Then
cmbPropType.AddItem TempArray(I, 9)
Endif
I = I + 1
Loop
RE: Remove non-consecutive duplicates from combobox
CODE
retstring = a.ReadLine
varText = Split(retstring, ",")
For J = 0 To intColumnCount + 2
varText = Split(retstring, ",")
TempArray(I, J) = varText(J)
Next J
''fills the combo box here
IsLoaded = False
For J = 0 To cmbPropType.ListCount - 1
If (cmbPropType.Column(0, J) = TempArray(I, 9)) Then
IsLoaded = True
Exit For
End If
Next ''Have to put a next here or it never gets into the loop
If (IsLoaded = False) Then
cmbPropType.AddItem TempArray(I, 9)
Endif
I = I + 1
Loop
RE: Remove non-consecutive duplicates from combobox