Hi All,

New to the forum. I've used Sue Mosher's ParseTextLinePair function (see below) before to retrieve data from the results of a web form that has been emailed to me but I've always sought ALL the data that appears after the data label. Eg. if the body of the email says:

NAME: John Smith
POSITION: Manager

I get "John Smith" from specifying strLabel as "NAME: " in my code. However I'm now looking to get just "John" so I'm guessing I need to try and swap the vbCrLf in the code below for a space somehow.

Anyone have any ideas how?

Cheers

Bob

Code:
Function ParseTextLinePair(strSource As String, strLabel As String)
    Dim intLocLabel As Integer
    Dim intLocCRLF As Integer
    Dim intLenLabel As Integer
    Dim strText As String
    
    intLocLabel = InStr(strSource, strLabel)
    
    intLenLabel = Len(strLabel)
    
        If intLocLabel > 0 Then
            intLocCRLF = InStr(intLocLabel, strSource, vbCrLf)
        If intLocCRLF > 0 Then
            intLocLabel = intLocLabel + intLenLabel
            strText = Mid(strSource, intLocLabel, intLocCRLF - intLocLabel)
        Else
            intLocLabel = Mid(strSource, intLocLabel + intLenLabel)
        End If
    End If

    ParseTextLinePair = Trim(strText)

End Function