Need a little help here. I must have a brainfart going on or something.
I have a Listview and a Listbox. The listview contains 3 columns (Filename, extension and size). I select a item in the list box and click add and it will add it to the list box.
I want to be able to remove it from the list box if I have added the wrong file. So I want to take the text from the listbox selected item and compare it to the text of the items by looping through all the items in the Listview.
No matter what I have tried, it never sees both items text values as the same, even if they are. I have tested to display the text via a message box and it looks right. code below. I am sure it is something with the code, but I cannot figure it out.
I have a Listview and a Listbox. The listview contains 3 columns (Filename, extension and size). I select a item in the list box and click add and it will add it to the list box.
I want to be able to remove it from the list box if I have added the wrong file. So I want to take the text from the listbox selected item and compare it to the text of the items by looping through all the items in the Listview.
No matter what I have tried, it never sees both items text values as the same, even if they are. I have tested to display the text via a message box and it looks right. code below. I am sure it is something with the code, but I cannot figure it out.
Code:
Dim ctext, rtext As String
Dim icount As Integer
rtext = ListBox1.SelectedItem
For icount = 0 To ListView1.Items.Count - 1
ctext = ListView1.Items(icount).Text
If ctext = rtext Then
'display 'found message
MsgBox("found")
Else
'display Not found message
MsgBox("not found")
End If
Next