Guus2005
06-26-2007, 12:17 PM
This function returns the n-th string
Public Function GetPart(strString As String, strSep As String, intPart As Integer) As String
Dim intFound As Integer
Dim intNext As Integer
intFound = InStr(1, strString, strSep)
If intFound > 0 Then
If intPart = 1 Then
GetPart = Mid$(strString, 1, intFound - 1)
Else 'intPart > 1
GetPart = GetPart(Mid$(strString, intFound + 1), strSep, intPart - 1) 'recursive
End If
Else 'intFound = 0, no occurence of seperator so return complete string
GetPart = strString
End If
End Function
Public Function GetPart(strString As String, strSep As String, intPart As Integer) As String
Dim intFound As Integer
Dim intNext As Integer
intFound = InStr(1, strString, strSep)
If intFound > 0 Then
If intPart = 1 Then
GetPart = Mid$(strString, 1, intFound - 1)
Else 'intPart > 1
GetPart = GetPart(Mid$(strString, intFound + 1), strSep, intPart - 1) 'recursive
End If
Else 'intFound = 0, no occurence of seperator so return complete string
GetPart = strString
End If
End Function