vb Code:
Public Function GetBetween(ByVal sSearch As String, ByVal sStart As String, ByVal sStop As String, _ Optional ByVal lSearch As Long = 1, Optional ByVal bCaseSensitive As Boolean = True) As String Dim lStart As Long, lStop As Long Dim lenStart As Long lenStart = Len(sStart) If bCaseSensitive = False Then lStart = InStr(lSearch, sSearch, sStart, vbTextCompare) + lenStart lStop = InStr(lStart, sSearch, sStop, vbTextCompare) Else lStart = InStr(lSearch, sSearch, sStart) + lenStart lStop = InStr(lStart, sSearch, sStop) End If If (lSearch + lenStart) <= lStart Then If lStart < lStop Then GetBetween = Mid$(sSearch, lStart, (lStop - lenStart - 1)) Exit Function End If End If GetBetween = vbNullString End Function
I am looking to make this as efficient as possible. =]




Reply With Quote