|
-
Sep 24th, 2004, 09:34 AM
#1
Thread Starter
Junior Member
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.
-
Sep 24th, 2004, 10:00 AM
#2
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," ")
-
Sep 24th, 2004, 10:08 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|