Module FindCommon Public Property npu As NPUWindow Function CountWholeWordFindMeAppearances(FindMeText, FindOptions, CaseSensitive) If npu.TextFileHolder.Find(FindMeText, 0, npu.TextFileHolder.TextLength, FindOptions) <> -1 Then Dim found As Integer = 0 Dim punctuation As String() = {" ", ",", "?", "!", ".", "…", vbNewLine} 'TODO: make sure this is how vb's native "whole word" function works Dim SearchText As String = npu.TextFileHolder.Text & " " Dim SearchSubString As String = FindMeText If Not CaseSensitive Then SearchText = SearchText.ToLower SearchSubString = SearchSubString.ToLower End If For i As Integer = 0 To SearchText.Length - FindMeText.Length - 1 For j = 0 To punctuation.Length - 1 If SearchText.Substring(i, FindMeText.Length + 1) = FindMeText & punctuation(j) Then found += 1 Next Next Return found - 1 'FOR YEARS I HAVE ENVIED / YOUR GRACE AND YOUR CHARM Else Return 0 End If End Function End Module