Hi. Can someone help.
I'm working with a list (not a listBox)
I have a list of staff called staffList and add a new staff member as staffList.add(staff), where staff is an object containing the staff members name and salary.
I have a staff class and a staffList class for methods and form1.
I want to be able to display a staff member from the list by entering the name (via an inputBox).
I can do it by index/ position in the list, but I want to do it by name.
How can I do this? By searching the list until I find a match? Do I use a boolean in a while statement, or a For...statement???
I tried this:
dim length as integer
dim index as integer
dim found as boolean
dim staffWanted as string
length = staffList.items.count
staffWanted = inputBox("enter staff name")
found = false
While (found = false) And (index < length)
If staffList.items(index) = staffWanted Then
found = true
index = index + 1
But it won't work as it won't accept staffList.items or (index). I think that must be because you use those with listBoxes but not lists.