' Find the first occurrence of forThisSubString 'return search position of wanted occurrenceĭim s As String: s = "this is a test to test to test" ' (three occurrencies of "test")ĭebug.Print "Occurrence " & i, "starts at position " & GetPosition(s, "tEst", i) N = n + (occurrence - 1) * Len(SearchString) + 1
'add substrings plus searchstring lengths
If occurrence UBound(part) Then Exit Function ' refuse too high occurrencies
'case sensitive? (case insensitive by default)įullText = LCase(FullText): SearchString = LCase(SearchString)ĭim part: part = Split(FullText, SearchString) ' split fulltext 'Purpose: get start position of a given search occurrence within fulltext Гибкая функция для поиска любого вхождения с использованием Split() может быть: Function GetPosition(ByVal FullText As String, ByVal SearchString As String, ByVal occurrence As Long, Optional ByVal CaseSensitive As Boolean = False) As Long