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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to replace line breaks....

Status
Not open for further replies.

debrac

IS-IT--Management
Jan 9, 2001
48
0
0
AU
I am trying to replace line breaks in a memo field from an Access database. How can i read the line breaks in a memo field?

Why doesnt this code work?
<%= rstSearch2.Fields(&quot;subtitle&quot;).Value %><br>
<%= Replace(rstSearch2.Fields(&quot;text&quot;).Value, vbCrLf, &quot;<BR>&quot;) %>
 


debrac,

Can you write the value of replace(rstSearch2.Fields(&quot;text&quot;).Value to see what is in the string?


fengshui1998
 
I had problems with that piece of code, but I got it working with this code:

poem=replace(poem,vbCrLf,&quot;<BR>&quot;)

The replace is a SUB, not a function, thus it needs to be called with an = to execute properly. Another technique would be placing the
<PRE>
in front of your ASP code and the
</PRE> after your code to have the results printout EXACTLY how they were entered into the DB (or how the DB stores it).
This includes FONT and anything.
 
Actually, the way I understood it, in the VB world if it returns a value it is a function, if it doesn't it is a sub or a function.

By stating this:
Code:
 <%= Replace(rstSearch2.Fields(&quot;text&quot;).Value, vbCrLf, &quot;<BR>&quot;) %>

You are assigning the result of the function to the Response buffer, exactly as if you had done this:
Code:
Dim a
a = replace(string1,findStr,repStr)
Response.Write a

Now, one possibility is that in the memo field the line breaks are not carriage-return line-feeds. You may want to try to use the carriage-return constant instead:
Code:
 <%= Replace(rstSearch2.Fields(&quot;text&quot;).Value, vbCr, &quot;<BR>&quot;) %>

If this doesn't work and Fengshui's method prints out the data from the field correctly (minus the linebreaks of course), post the code for that area and we will take a closer look. Also posting a sample from the table would help as well (copy and paste directly and turn TGML off for your post before posting so we can see the line breaks.)

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top