Function variable
Posted by Ben on September 17, 2000 9:23 AM
I can't figure this one out. This function returns an error when called with "If isinbox("Name", Listbox1)..." because ListBox1 returns it's selected string:
Function isinbox(mystring As String, lb As ListBox) As Boolean
Dim i As Integer
For i = 0 To lb.ListCount - 1
If UCase(mystring) = UCase(lb.List(i)) Then
isinbox = True
Exit Function
Else: isinbox = False
End If
Next i
End Function
It works fine w/o ListBox variable:
Function isinbox(mystring As String) As Boolean
Dim i As Integer
For i = 0 To ListBox1.ListCount - 1
If UCase(mystring) = UCase(ListBox1.List(i)) Then
isinbox = True
Exit Function
Else: isinbox = False
End If
Next i
End Function
...except that it requires a function for each listbox. How do I resolve the type mismatch?