devxlogo

Use GetBetween to Parse a String Between Two Strings

Use GetBetween to Parse a String Between Two Strings

This tips shows how to use GetBetween to parse and extract a string between two strings. GetBetween returns the extracted string, if found.

Public Function GetBetween(ByRef sSearch As String, ByRef sStart As String, ByRef sStop As String, _                                                    Optional ByRef lSearch As Long = 1) As String    lSearch = InStr(lSearch, sSearch, sStart)    If lSearch > 0 Then        lSearch = lSearch + Len(sStart)        Dim lTemp As Long        lTemp = InStr(lSearch, sSearch, sStop)        If lTemp > lSearch Then            GetBetween = Mid$(sSearch, lSearch, lTemp - lSearch)        End If    End IfEnd Function

devx-admin

Share the Post: