CONTAINS

CONTAINS(text1, text2, ignore_case)
Returns whether a string is contained inside another string.

text1The text string containing your substring.
text2The text string to look for.
ignore_case(Optional) Whether you want to ignore the case of the text.

REMARKS
* If "IgnoreCase" is left blank, then False is used.
* This function can include wildcards.

 A
1=JS.CONTAINS("text","sometext")
2=JS.CONTAINS("TEXT","sometext",TRUE)
3=JS.CONTAINS("TEXT","sometext",FALSE)
4=JS.CONTAINS("one","londoner")
51 - Does the text "some text" contain the substring "text".

Public Function CONTAINS( _ 
         ByVal sText1 As String, _
         ByVal sText2 As String, _
Optional ByVal bIgnoreCase As Boolean = False) _
         As Boolean
                
   Call Application.Volatile(True)
                
   CONTAINS = False
   If Len(sText1) = 0 Or Len(sText2) = 0 Then Exit Function
   
   If bIgnoreCase = False Then
      If UCase(sText2) Like "*" & UCase(sText1) & "*" Then
         CONTAINS = True
      End If
   Else
      If sText2 Like "*" & sText1 & "*" Then
         CONTAINS = True
      End If
   End If
End Function

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext