Remove Carriage Returns

Discussion in 'ASP General' started by Simon Harris, Apr 27, 2005.

  1. Simon Harris

    Simon Harris Guest

    Hi All,

    I am trying to write a function that will remove all carriage returns from
    a
    string, so that the string of words can be used as meta keywords.

    So far I have:

    Function RemoveCR(strText)
    strText = Replace(strText,chr(13),"")
    strText = Replace(strText,chr(10),"")
    strText = Replace(strText,vbCrLf ,"VISUALBASIC")
    RemoveCR = strText
    End Function

    My string still ends up with carriage returns in it though! I don't get
    it,
    what did I miss?

    Thanks,
    Simon.
     
    Simon Harris, Apr 27, 2005
    #1
    1. Advertisements

  2. well, that looks pretty good really at 1st glance but it must be missing
    something ?


    I usually just do this in my own code when I log inot ot a text file and it
    usually gets everything for me
    You might want to try checking to 3 things my function looks for

    The reason why I have a fix part is because I sometimes have many scenarios
    in my function and this way I can have one function that can do a bunch of
    things


    Function FixStr(StrToFix,FixHow)

    If Not IsNull(StrToFix) and StrToFix <> "" Then

    If FixHow = "PrepareForLogfile" then
    StrToFix = Replace(StrToFix,vbCrLf," ")
    StrToFix = Replace(StrToFix,vbLf," ")
    StrToFix = Replace(StrToFix,vbNewLine," ")
    End If

    End If

    FixStr = StrToFix
    End function



    FixStr(Request("address_street"),"PrepareForLogfile")
     
    Kyle Peterson, Apr 27, 2005
    #2
    1. Advertisements

  3. The first two lines are overkill. In fact, they will prevent the third line
    from doing anything. vbCrLf is a constant that is equivalent to chr(13) &
    chr(10).

    I guess we need to see strText in order to see what is wrong. Are you sure
    it does not contain html? Particularly "<BR>"?

    Bob Barrows
     
    Bob Barrows [MVP], Apr 28, 2005
    #3
  4. Simon Harris

    Simon Harris Guest

    Hi,

    Many thanks for the replies.

    Seems I was calling my function incorrectly, or at the wrong time.

    Simon.
     
    Simon Harris, Apr 29, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.