您也可以使用特殊词like:Public Sub Search() If "My Big String with, in the middle" Like "*,*" Then Debug.Print ("Found ','") End IfEnd Sub
您还可以编写一个函数,如果存在子字符串,则返回TRUE,否则返回FALSE:Public Function Contains(strBaseString As String, strSearchTerm As String) As Boolean'Purpose: Returns TRUE if one string exists within anotherOn Error GoTo ErrorMessage Contains = InStr(strBaseString, strSearchTerm)Exit FunctionErrorMessage:MsgBox "The database has generated an error. Please contact the database administrator, quoting the following error message: '" & Err.Description & "'", vbCritical, "Database Error"EndEnd Function