Public Function GetInBetween(strStartChar As String, _
strEndChar As String, _ strStringToSearch As String) As String On Error Goto GetInBetween_ErrorHandler '(Default) extract servername 'from in between {} 'returns <nf> if not found Dim intFirstOne As Integer Dim intSecondOne As Integer Dim intLength As Integer Dim strTemp As String intFirstOne = InStr(strStringToSearch, strStartChar) intSecondOne = InStr(intFirstOne + 1, strStringToSearch, strEndChar) If intFirstOne = 0 Then Goto ErrorInFunction If intSecondOne = 0 Then Goto ErrorInFunction intLength = intSecondOne - intFirstOne strTemp = Mid(strStringToSearch, intFirstOne, intLength) GetInBetween = Right(strTemp, Len(strTemp) - 1) Exit Function ErrorInFunction: GetInBetween = "<nf>" '---- Code Body Ends ---- (Default) Exit Function GetInBetween_ErrorHandler: ErrorLog.WriteToLog "Error " & Err.Number & _ ": " & Space(12) & vbCrLf & Err.Description & _ Space(12) & vbCrLf & "Occurred at line " & _ Erl & " in " & app.title & ": Module1.GetInBetween" Select Case MsgBox("Error " & Err.Number & ": " & vbCrLf & _ Err.Description & vbCrLf & "Occurred at line " & _ Erl & " in " & app.title & ": Module1.GetInBetween", _ vbAbortRetryIgnore + vbExclamation, app.title & " Error.") Case vbAbort Resume Exit_GetInBetween Case vbRetry Resume Case vbIgnore Resume Next End Select Exit_GetInBetween: End Function Inputs: strStartChar - First BookEnd character strEndChar - Second BookEnd character strStringToSearch - string With text |