CodeItBetter Programming Another VB Programming Blog

How to return everything between ‘string2′ in ‘string1′

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
'String Manipulation - How to return everything between 'string2' in 'string1'
Option Explicit
 
Public Function GetStringBetween(ByVal sExpression As String, ByVal sStartString As String, _
    ByVal sEndString As String) As String
    Dim iStartPos As Integer, iEndPos As Integer
    iStartPos = InStr(sExpression, sStartString)
    iEndPos = InStr(sExpression, sEndString)
    If iStartPos <> iEndPos And iStartPos <> 0 And iEndPos <> 0 Then
        GetStringBetween = Mid$(sExpression, iStartPos + Len(sStartString), iEndPos - 1)
    End If
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.