Hi. What would be the suitable approach to check if a variable matches with any string from another cell. Example:
ListOfItems variable = Bag of Chips Cocktail table Individual Salad Sandwich
ColumnList variable = Service Request Cocktail
So basically I want to check if the ListOfItems variable contains/matches any string inside the ColumnList variable. There could be a lot of values inside the variables so is there a suitable approach to be able to check if the ListOfItems variable matches any string inside the ColumnList variable
I tried using the ColumnList.Contains(ListOfItems) and it didn’t work correctly because I need to be able to return it True if it matches any word between both variables not just the whole thing
I tried the suggested approach but it kept returning that it matches each time even if the listofitems didn’t have a string that matched anything inside the columnlist variable. Originally these variables were under string variable type also. In your default column above, the strings could be any value or could have a huge number of strings also.
As I wouldn’t know what strings could be inside one variable because it is a different one each time it reads the data from an excel cell where it’s then assigned into a variable like all of the data Powerboard
Flipchart
White Board would be in one cell and then assigned into a variable.
So what you have assigned using New List(Of String)From{“Powerboard”,“Flipchart”,“White Board”}
Instead of putting in the strings examples - I replaced it with a variable with all the data will be read
New List(Of String)From{ListOfItems}
New List(Of String)From{ColumnList}
Somehow it doesn’t seem to do the job right as not recognising anything inside the variables and comparing/matching any word in order to return true/false result if there’s any matches
Which type is ListOfItems and ColumnList? It seems String type if the above expression show no error. We can see content of the list at locals panel, if set Breakpoint and run debug. Can you check it?
Ah brilliant thanks so much, that works much better however there may be some strings for example if the ListOfItems had a part string whereas in the ColumnList may have a full string labelled so it wouldn’t match when I need it to be. For example in the ListOfItems variable it has Fixed Projector where it matches a partial string in the ColumnList variable despite not having Screen in that string. Is it doable to be able to match partial strings?
ColumnList could contain:
Electronic White Board
Fixed Data Projector
Fixed Projector Screen
Flipchart
ListOfItems could contain:
Fixed Projector
Random Word
Test
I’m looking for the output to be true because Fixed Projector in ListOfItem variable matches where Fixed Projector in theColumnList variable is mentioned