Option Compare Database
Option Explicit
Function fRemoveSymbols(strMemo, strChrSearch As String) As String
On Error Resume Next 'Required if used on the current event
Dim strNewString As String 'The controls new value
Dim intLength As Integer 'The passed strings length
Dim intStartPos As Integer 'Sets a starting position within the string
Dim intEndPos As Integer 'Sets the found position within the string
Dim intNumChrReturn As Integer 'Returns Number of characters in specfic string
intLength = Len(strMemo)
intStartPos = 1
intEndPos = InStr(intStartPos, strMemo, strChrSearch)
'Add 1st line, Use Trim to remove any leading/trailing spaces
strNewString = Trim(Mid(strMemo, intStartPos, (intEndPos - 1)))
Do Until intEndPos = intLength
'Set new starting point for search
intStartPos = intEndPos + 2 '+2 for Pipe and Carriage Return
'Find the next character in the string.
intEndPos = InStr(intStartPos, strMemo, strChrSearch)
If intEndPos = 0 Then 'No more symbols found, We must be at the end!
intEndPos = intLength 'Set exit point
Else
'Get the length of the next line in characters
intNumChrReturn = intEndPos - intStartPos
'Add the next line to the current string
'Use Trim to remove any leading/trailing spaces
strNewString = strNewString & vbCr & Trim(Mid(strMemo, intStartPos, intNumChrReturn))
End If
Loop
fRemoveSymbols = strNewString
End Function