bjay
08-30-2014, 02:04 PM
Hello all;
I'm trying to find an answer for the following with no luck. I'm a beginner level programmer, and hoping someone will point me in the right direction.
I need to know if a string contains part of another string.
Eg:
strFirst = "Mid Century Modern"
strTwo = "Mid Century Modern Sofa"
As you see, both have the string "Mid Century Modern"
So, I want to write a function that will loop through several strings and check if this is true.
I have tried, InStr(), but didn't get the result I want. Also, I'm playing with the following code but cannot get this to work (although not sure if this is the way to go)
Function test()
Dim TestString As String
Dim TestString2 As String
TestString = "Mid Century Modern"
TestString2 = "Mid Century Modern Sofa"
Dim TestArray() As String
Dim TestArray2() As String
TestArray() = Split(TestString)
TestArray2() = Split(TestString2)
Dim Str As Variant
For Each Str In TestArray2
If Filter(TestArray2, Str, True) Then ' **** it gives me a type mismatch on this line****
MsgBox "found"
End If
Next
End Function
Please help! I appreciate your time. Thanks
BJ
I'm trying to find an answer for the following with no luck. I'm a beginner level programmer, and hoping someone will point me in the right direction.
I need to know if a string contains part of another string.
Eg:
strFirst = "Mid Century Modern"
strTwo = "Mid Century Modern Sofa"
As you see, both have the string "Mid Century Modern"
So, I want to write a function that will loop through several strings and check if this is true.
I have tried, InStr(), but didn't get the result I want. Also, I'm playing with the following code but cannot get this to work (although not sure if this is the way to go)
Function test()
Dim TestString As String
Dim TestString2 As String
TestString = "Mid Century Modern"
TestString2 = "Mid Century Modern Sofa"
Dim TestArray() As String
Dim TestArray2() As String
TestArray() = Split(TestString)
TestArray2() = Split(TestString2)
Dim Str As Variant
For Each Str In TestArray2
If Filter(TestArray2, Str, True) Then ' **** it gives me a type mismatch on this line****
MsgBox "found"
End If
Next
End Function
Please help! I appreciate your time. Thanks
BJ