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

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
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 @

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:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



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