Search with InStr function for multiple words in a string
<p>I have a problem finding one or more keywords within a string.</p>
<p>I've been helped on the way by <a href="https://stackoverflow.com/a/24972568">https://stackoverflow.com/a/24972568</a>. The code limits the search to the first word in the string.
It is pointed out in the answer:</p>
<blockquote>
<p>Remember that <em>starts with</em> is different from <em>contains</em>.</p>
</blockquote>
<p>I tried changing the parts of the code that uses <code>StringStarts</code> to <code>Contains</code>.</p>
<pre class="lang-vb prettyprint-override"><code>If StringStarts(Me.gname.Value, &quot;Mr&quot;, &quot;Mrs&quot;, &quot;Dr&quot;, &quot;Supreme Commander&quot;, &quot;Capt.&quot;) Then
    MsgBox &quot;Consumer Name Starts with Mr./Mrs./Ms./Dr. Check Consumer Name&quot;
    '... 
    
Function StringStarts(strCheck As String, ParamArray anyOf()) As Boolean
    Dim item As Long
    For item = 0 To UBound(anyOf)
        If InStr(1, strCheck, anyOf(item), vbTextCompare) = 1 Then
            StringStarts = True
            Exit Function
        End If
    Next
End Function
</code></pre>