Hey all... Im trying to use an object collection to try and compare variables in a listbox... The thing is when a button is clicked and the variable in the 1st listbox is seen as a duplicate no matter if there is the same value present or not...
Even if I comment/uncomment the values in the if block it still does not accept a value - Even if it is not present in the listbox...
Any ideas where I am going wrong? or another way of achieving my goal?
Code:
Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
Dim cache As New ListDictionary
Over here, the code to detect a click. Then...
If Not cache.Contains(lstSelected.SelectedIndex) Then
cache.Add(lstSelected.SelectedIndex, "") Note that the value is irrelevant...were only interested in the key.
Else
Throw New Exception Do whatever to handle this.
End If
Carry on with whatever...
Try
FoundMatch()
If Not cache.Contains(lstSelected.SelectedIndex) Then
MsgBox("Duplicate Entry", MsgBoxStyle.OKOnly, "Duplication Error")
lstSelected.Items.Add(lstSelect.Text)
lstSelect.Items.Remove(lstSelect.Text)
ElseIf cache.Contains(lstSelected.SelectedIndex) Then
lstSelected.Items.Add(lstSelect.Text)
lstSelect.Items.Remove(lstSelect.Text)
MsgBox("Duplicate Entry", MsgBoxStyle.OKOnly, "Duplication Error")
End If
Catch ex As Exception
MsgBox("Error Type : " & Err.Description, MsgBoxStyle.Exclamation, "Error Number : " & Err.Number)
End Try
End Sub
Even if I comment/uncomment the values in the if block it still does not accept a value - Even if it is not present in the listbox...
Any ideas where I am going wrong? or another way of achieving my goal?