How to find a string between two substring on a given string phrase
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 'String Manipulation - How to find a string between two substring on a given string phrase Option Explicit Sub Main() Debug.Print ParseStringBetweenTwoCharacters("This is a Test phrase <Find> for this example.", "<", ">") End Sub Private Function ParseStringBetweenTwoCharacters(ByVal sText As String, ByVal sFind1 As String, ByVal sFind2 As String) As String Dim iPos1 As Integer, iPos2 As Integer iPos1 = InStr(1, sText, sFind1) iPos2 = InStr(iPos1 + Len(sFind1), sText, sFind2) ParseStringBetweenTwoCharacters = Mid$(sText, iPos1 + Len(sFind1), iPos2 - (iPos1 + Len(sFind1))) End Function |