-
I'm still not having any luck. Any help is appreciated.
I'm grabbing text from four texboxes and adding it to a list view with four columns with the click of a button. What is the Syntax for checking if the data I'm about to add to the listview already exists? Here's my current code that adds data to my columns.
Private Sub cmdAddToListView_Click()
Set sitem = lstCustomers.ListItems.Add(, , txtFields(1).Text)
sItem.SubItems(1) = txtFields(2).Text
sItem.SubItems(2) = txtFields(3).Text
sItem.SubItems(3) = txtFields(4).Text
End Sub
-
This worked for me, a simple loop to check the sub item with the entry being added. This code removed the matched item in the list view
For LoopCounter = 1 To ListCount
lngVariable1 = Val(lstListView.ListItems.Item_(LoopCounter).SubItems(1))
If lngVariable1 = lngVariable2 Then
'if there is a match remove the entry in the list box
lstListView.ListItems.Remove (LoopCounter)
ListCount = ListCount - 1
Exit For
End If
Next LoopCounter