CodeItBetter Programming Another VB Programming Blog

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

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
'String Manipulation - How to return everything before 'string2' in 'string1'
Option Explicit
 
Public Function SubstringBefore(ByVal sString1 As String, ByVal sString2 As String)
    Dim iPos As Integer
    iPos = InStr(sString1, sString2)
    If iPos <> 0 Then
        SubstringBefore = Mid$(sString1, 1, iPos - 1)
    End If
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.