473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Displaying carriage returns in a memo field

Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.

I figured I might be able to use:
'replace carriage returns with BRs
comment=Replace(comment, chr(13), "<br>")
but obviously net.!

The <pre> tag doesn't sem to help either as the embedded return is
lost by the time you get past Request.Form......

thanks

.les.
Aug 26 '05 #1
4 7298
I've never had a problem using Replace(), but I use chr(10) or vbCrLf, not
chr(13). I also only doing this when *displaying* the data, not when
storing it. I'm not sure why you think "the embedded return is lost"
because it is not. Could you show some sample code that reproduces this
problem?

http://www.aspfaq.com/2188

A
"Les Juby" <le*****@anti-spam.iafrica.com> wrote in message
news:43***************@news.telkomsa.net...
Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.

I figured I might be able to use:
'replace carriage returns with BRs
comment=Replace(comment, chr(13), "<br>")
but obviously net.!

The <pre> tag doesn't sem to help either as the embedded return is
lost by the time you get past Request.Form......

thanks

.les.

Aug 26 '05 #2
Uuuuuuhh..... it was the chr(13) instead of chr(10)

A throwback to dBase and the old DOS days.

Works great, thanks for the help !

.les.
On Fri, 26 Aug 2005 16:15:18 -0400, "Aaron Bertrand [SQL Server MVP]"
<te*****@dnartreb.noraa> wrote:
I've never had a problem using Replace(), but I use chr(10) or vbCrLf, not
chr(13). I also only doing this when *displaying* the data, not when
storing it. I'm not sure why you think "the embedded return is lost"
because it is not. Could you show some sample code that reproduces this
problem?

http://www.aspfaq.com/2188

A
"Les Juby" <le*****@anti-spam.iafrica.com> wrote in message
news:43***************@news.telkomsa.net...
Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.

I figured I might be able to use:
'replace carriage returns with BRs
comment=Replace(comment, chr(13), "<br>")
but obviously net.!

The <pre> tag doesn't sem to help either as the embedded return is
lost by the time you get past Request.Form......

thanks

.les.


Aug 26 '05 #3
Aaron Bertrand [SQL Server MVP] wrote:
I've never had a problem using Replace(), but I use chr(10)
or vbCrLf, not chr(13). I also only doing this when
*displaying* the data, not when storing it. I'm not sure why
you think "the embedded return is lost" because it is not.
Could you show some sample code that reproduces this problem?


Since the OP did not elaborate, I would like to offer this observation:
*Leading* carriage returns are not rendered by some browsers[1], meaning
they must be accounted for in post-back situations.

In other words, if you have something like this...

<textarea name="txt"><%=Request.Form("txt").Item%></textarea>

....and type the equivalent of "\r\nTest\r\n" (or: vbCrLf & "Test" & vbCrLf),
then the resulting HTML source is...

<textarea name="txt">
Test
</textarea>

....which is rendered in the browser identically to this:

<textarea name="txt">Test
</textarea>

Note that the carriage return was not lost in the form submission, as the
resultant HTML source properly contains it. Furthermore, the *trailing*
carriage returns are retained. It is an oddity, but not the only one.
Displaying the text outside the form control is a whole other animal.

Consider what happens when the following are added to my example:

<style type="text/css">
div { border:solid 1px #ccc; white-space:pre; }
pre { border:solid 1px #ccc; }
</style>
<div><%=Server.HTMLEncode(Request.Form("txt").Item )%></div>
<pre><%=Server.HTMLEncode(Request.Form("txt").Item )%></pre>
<div><%=Request.Form("txt").Item%></div>
<pre><%=Request.Form("txt").Item%></pre>

In all tested browsers, neither leading nor trailing carriage returns are
rendered <pre> in here </pre>. IE treats <div style="white-space:pre;">
identically. Opera and Firefox retain the leading carriage returns, but lost
the trailing ones. In all three browsers, the "white-space:pre" rendering
conflicts with that of <textarea>. It's no wonder the OP might think his
carriage returns are being lost.

[1] IE and Firefox, at a minimum. Opera does not lose them. UAs tested:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; en) Opera 8.01
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.7.10) Gecko/20050716
Firefox/1.0.6
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322;
..NET CLR 1.0.3705; .NET CLR 2.0.40607)

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Aug 26 '05 #4
Here's what has worked for me although I usually put it into a function:

' Convert all vbCrLf to <br>.
' (This is the same as converting Chr(13) & Chr(10) to <br>.)
varFld = Replace(varFld, vbCrLf, "<br>")

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

<<
Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.

I figured I might be able to use:
'replace carriage returns with BRs
comment=Replace(comment, chr(13), "<br>")
but obviously net.!

The <pre> tag doesn't sem to help either as the embedded return is
lost by the time you get past Request.Form......


*** Sent via Developersdex http://www.developersdex.com ***
Aug 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
3
by: Steve Leferve | last post by:
I'm making a report that uses a query as its source. The query references a memo field that typically has carriage returns in it. When I go to run the report, it seems to have truncated the fields...
3
by: Dave | last post by:
I need to strip out carriage returns from a memo field. Basically, one of the commercial databases we have uses a memo field for the address, and what I'd like to do is get rid of the carriage...
2
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
1
by: I am Sam | last post by:
In ASP using VBScript to replace Chr(13) or Chr(10) with a <br> tag I would use the Replace method so that I can catch carriage returns from a memo field in MS Access or a Text field in MS SQL...
3
by: raj chahal | last post by:
Hi there I've created a db field with Memo type, and I have stored some text with carriage returns (no html) So the 3 words start on a differnt line. In access this displays correctly ( each...
3
by: Gillian Steele | last post by:
I'm trying to import data into a memo field by running an append query. The data is to be imported as if it was entered with separate lines in the memo field. I have tried inserting chr(13)s...
6
by: Bhujanga | last post by:
Is there a way to set a memo field on a form so that the 'Enter' key will behave as a carriage return instead of leaving the field? I know the field type recognizes carriage returns if you feed them...
1
by: jollyroger | last post by:
I have searched the web forums, and can't seem to find an answer to this particular problem I have. In an excel sheet, cells in one column have formatted text in the "wrapped" cells. For many of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.