ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
Migrating to ASP.NET
Getting Scripts to Run on a Schedule
The Top 10 ASP Links @ Microsoft.com

QUICK TIP:
Previewing ASP pages in Visual InterDev 6.0
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Quick Tips


Using " in your Strings

When you're first getting started in VBScript, one of the most confusing things is how to use the " character within a string. Since VBScript uses " as its string delimiter, if you try and use one inside of a string, it thinks the string is ending and will usually give you an error since it tries to interpret the rest of the string as a VBScript command.

This leads many developers to use Chr(34) to build their strings like this:

<%
Response.Write "He said " & Chr(34) & "ASP Rocks!" & Chr(34) & " and left."
%>

While that works fine, it requires you to break out into VBScript and then back into the string in order to continue and VBScript actually has to do some work to concatenate the pieces together. On top of it all you have to remember that it's character 34! Try this alternative:

<%
Response.Write "He said ""ASP Rocks!"" and left."
%>

I don't like typing more then I have to and I like to be able to read my code. Maybe it's just me, but I feel this is much more readable and I save typing on top of it all!

Oh and another quick tip... if you get confused about how many " characters you need, count them... there should always be an even number on any given line. (So is that's a sub-quick tip or a quick quick tip?!?)


Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to: webmaster@asp101.com.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers