Comparing text strings and not getting correct answers

Comparing text strings and not getting correct answers

SteveK88
Advocate Advocate
194 Views
1 Reply
Message 1 of 2

Comparing text strings and not getting correct answers

SteveK88
Advocate
Advocate

Hi,  I am comparing Text strings and not getting the list of results I want.  I am using 'contains' and am looking to find all the text strings that are found in "B-ananas" using a list. The expected result should contain 4 answers because of 'contains' but I only get one result   Please take a look.

here is the code....

 

Dim oSTr As String
oSTr = "B-ananas"
'FilterName = "na"
'FilterName = "B-"

	'Add Select Cases for Filter Terms
	Dim FilterValue As New List(Of String) ' List starts at 0
		FilterValue.Add("PartName1")
		FilterValue.Add("B-")
		FilterValue.Add("xB-")
		FilterValue.Add("sss B- xx")
		FilterValue.Add("sss b- xx")

Dim FilterName As String

For Each FilterName In FilterValue 
			If oSTr.Contains(FilterName) Then
			MsgBox("oStr = " & oSTr & ", FilterName = " & FilterName)
		End If
Next
0 Likes
195 Views
1 Reply
Reply (1)
Message 2 of 2

SteveK88
Advocate
Advocate

Forget it.  bad data.  works fine.

Dim oSTr As String
oSTr = "B-"

	'Add Select Cases for Filter Terms
	Dim FilterValue As New List(Of String) ' List starts at 0
		FilterValue.Add("PartName1")
		FilterValue.Add("B-")
		FilterValue.Add("xB-")
		FilterValue.Add("sss B- xx")
		FilterValue.Add("sss b- xx")

Dim FilterName As String

For Each FilterName In FilterValue 
			'If oSTr.Contains(FilterName) Then
				If FilterName.Contains(oSTr) Then
			MsgBox("oStr = " & oSTr & ", FilterName = " & FilterName)
		End If
Next