I've been trying to use callbyname to write a generic function which checks if the target list (targetListName) contains a certain item before adding it to the list. Unfortunately, I can't seem to figure out how to use .contains with callbyname. Appreciate any help!
This is the code I'm using now. Supply and Demand are both lists(of string).
Public Sub addItem(ByVal item As String, ByVal targetListName As String)
Select Case targetListName.ToLower
Case "supply"
If supply.Contains(item) = False Then supply.Add(targetListName)
Case "demand"
If demand.Contains(item) = False Then supply.Add(targetListName)
Case Else
'bugcatch
End Select
End Sub
I would like to ideally use something like this instead:
Public Sub addItem(ByVal item As String, ByVal targetListName As String)
If CallByName(Me, targetListName, [Method]).Contains(item) = false Then
CallByName(Me, targetListName, [Set]).Add(item)
End If
End Sub