FredixBlog


Just my log about anything I could find enjoyable.



Clear all line breaks

author Posted by: fredometro on date Jan 6th, 2004 | filed Filed under: MS-Access

Quertion: Can anyone figure out a little function that will clear all line breaks (Chr(10)+Chr(13)) in a string?
Matt(+)

Fredix gave this response on 1/17/2002:
Hi!

Here is a function I use:

Public Function ClearBreaks(TheString)
dim ch, result as string
dim i as integer

    result = “”
    if len(TheString) = 0 then
        ClearBreaks = “”
        exit function
    end if

    for i = 1 to len(TheString)
        ch = mid(TheString,i,1)
        if ch <> chr(13) and ch <> chr(10) then
            result = result & ch
        else
            if ch = chr(13) then result = result & ” ”
        end if
    next i

    ClearBreaks = result

end function

With this, you will have the line breaks replaced by a space.

Regards.