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!

vbcrlf not working in ASP code

Status
Not open for further replies.

NewASPGuy

Programmer
Jan 6, 2005
2
US

The vbcrlf is not working, it writes all on one line. Below is a sample of the code.

<%
Response.write Request.Form("fName") & " " & Request.Form("lName") & vbcrlf
Response.write Request.Form("sAddress") & vbcrlf
Response.write Request.Form("City") & ", " & Request.Form("State") & " " & Request.Form("Zip") & vbcrlf & vbcrlf


Please help
 
Hello NewASPGuy,

You've to write "&nbsp;" for the effect of a html space. As to the effect of vbcrlf, you can write a empty tag "<br />". For more sophisticated layout, you might have to consider a table, tag <p> etc.
[tt]
Response.write Request.Form("fName") & "&nbsp;" & Request.Form("lName") & "<br />"
[/tt]
We have dedicated asp forum as well
in case you do not know.

regards - tsuji
 
Thanks, "<BR>" worked great, didn't have to use the "&nbsp;" though, " " worked fine, which brings up my real question....I have been programming in VB for years and from what I understand as long as the <%@ Language=VBScript %> is declared at the top of the ASP page and the code is wrapped in <% %> then it acts like VB code, technicaly VBScript so why did the vbcrlf not work forcing me to send the HTML equivalent "<BR>" as you sugested?
 
how will the engine know to convert vbcflf to "<BR>"?
 
Sending a newline to the browser has a specific meaning. It means new line, whether you are sending CrLf, Lf, or Cr shouldn't matter much. Most browsers are made so they treat all 3 possibilities as a "new line" indication. A Unix server may send Lf, a Mac may send Cr - the browser can't be picky.

Truth is, to create a logical newline you're supposed to use the vbNewline constant, which varies with the platform it is used on and sends the "native newline" for that platform. For Windows that'd be CrLf.

But this doesn't mean "display the following text on a new line" in HTML. HTML rendering doesn't pay (much) attention to newline symbols. The line break markup tag <B> has a separate specific meaning to the browser entirely, involving presentation. This is one way that content can be forced to render on a "new line." Within the body text a newline really gets treated as simple whitespace, like a space character.

One reason all this makes a difference is that newline is important in any client script you send to the browser.

Imagine you want to send the browser some VBScript or Javascript. In these languages, line breaks are significant to indicate the end of a statement for simple single-line statements:

[tt]<script language=vbscript>
Dim X
Dim Y

X = 12 + 3
Y = 47
</script>[/tt]

VBScript needs those newlines at the end of each line. If ASP changed all newlines to <B> you'd have syntax errors.

I hope that makes sense.
 
*sigh*

Yes, where I wrote <B> I meant <BR>!

Back to the coffee, I guess.
 
thanks, as usual, for the clarification 'dilettante', ps how does one pronounce your handle??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top