Results 1 to 3 of 3

Thread: Replacing a "Return Character" with a Space in a String [RESOLVED]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2003
    Posts
    18

    Resolved Replacing a "Return Character" with a Space in a String [RESOLVED]

    Hi all,

    I am selecting a comment field from my database and some of the comments contain a "return character" ("||"). When I print these out, the return character forces a new line on the printout, which I do not want. How can I replace a return character in a string with a space?

    Example:

    Dim String1(100) As String

    * Open DB
    * Select Recordset
    x = 0
    Do while not RS.EOF
    x = x + 1
    String1(x) = RS(0)
    Loop
    * Close Recordset
    * Close DB

    * now I'd like to search through the array of strings and replace Returns with Spaces

    Any help would be greatly appreciated.
    Last edited by smh295; Sep 24th, 2004 at 10:10 AM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    First, rather than loading an array in code, check out the GetRows or GetString methods of the Recordset object. Both create an array based on the paramters you pass.

    Use the Replace function to change the carriage return/line feeds. Using one or more of the following should work.

    String(x) = Replace(String(x), vbCRLF," ")
    String(x) = Replace(String(x), vbCR," ")
    String(x) = Replace(String(x), vbLF," ")

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2003
    Posts
    18
    Originally posted by brucevde

    String(x) = Replace(String(x), vbCRLF," ")
    This is exactly what I was looking for. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width