Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace function for a string

Status
Not open for further replies.

Stoemp

Programmer
Sep 25, 2002
389
BE
I use the Replace function to replace the CrLf's I have in some text in databases. The fields are all of the 'memo'-type (in Dutch. I don't know if it's the same in english. It's a long text type).

In one case all the vbCrLf's are replaced with <br>'s and in the other case (same code, same database settings) it does not work. Here's the code I use:

sRef = RS_products(&quot;referentie_Nr&quot;)
If ( sRef <> &quot;&quot; ) Then
sRef = CStr(Replace(sRef, vbCrLf, &quot;<br>&quot;))
Else sRef = &quot;&quot;
End If

sDescr = RS_products(&quot;lange_beschr_&quot; & sLang)
If ( sDescr <> &quot;&quot; ) Then
sDescr = CStr(Replace(sDescr, vbCrLf,&quot;<br>&quot;))
Else sDescr = &quot;&quot;
End If

What am I doing wrong? The vbCrLf's in the database are made with Ctrl+enter in both cases. The first case works, the second one doesn't. Very weird if you ask me for an opinion...
 
Only thing I can think of to try is:

Change the vbcrlf to chr(13) and see if it makes a difference. &quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
It doesn't make any difference. :-(
This is not possible, isn't it?

Pfffff...
 
Hi Stoemp,

Try parsing the vbCrLf, vbCr AND vbLf. The vbcrlf will only parse out the CR + LF combo. if you also use vbCR it will check only for CR's and the same goes for vbLF..

This should solve your issue.

Cheers,

G.
 
Try This:

REPLACE(REPLACE(yourString,CHAR(10),''),CHAR(13),'')
 
I've run into problems in SQL Server and Crystal Reports where their replace function wouldn't work on a &quot;memo&quot; field. Is it possible that it's only working on fields where the length is less than 255 characters? Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top