DEV Community

vblover programmer
vblover programmer

Posted on

VB .Net: Find words in String Array Extension Method

Definition:

 <Extension()>
    Function ExistsIn(value As String, ParamArray FieldValues() As String) As Boolean
        For Each FieldValue As String In FieldValues
            If FieldValue.ToLower.Contains(value.ToLower) Then Return True
        Next
        Return False
    End Function
Enter fullscreen mode Exit fullscreen mode

Usage:

Dim Value As String = "Love"
Debug.Print("{0}",value.ExistsIn("VBLover","vblover","vbloverprogrammer"))
Enter fullscreen mode Exit fullscreen mode

Returns: True

Top comments (0)