You can start thinking of the problem you've mentioned in the following line:
MsgBox(txtSearchItem.Text & " was found, with a mark of " & frmStudentDatabase.ListView1.Items(txtSearchItem.Text).SubItems(1).Text)
if your code passes successfully the condition to get to execute the line for showing a message including the student mark then it means you don't have to ask the ListView1 to find the same item again, right?P.S.
when you ask ListView1.Items()
to find an item for you you should either use an Integer
(Indicating the index of the item you're looking for) or a String
(Indicating the key [Name
] of the item you're looking for) so both of them have nothing to do with the item's text and so if the items key or name is not set then ListView1.Items(
won't give result.
now you can modify the conditional block statements above to be like this:
MsgBox(txtSearchItem.Text & " was found, with a mark of " & SearchItem.SubItems(1).Text)
SearchItem.Selected = True
Test it and get back to us, if nothing seems to happen then please add a msgbox call function before hiding the current form, in code:
Add something like -> MsgBox("Found An Item!")
Before this line -> Me.Hide()