Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 05, 2002

Rem: Understanding Quotation Marks in VBScript


RSS
View this exclusive article with VIP access -- click here to join |
See More VBScript Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

I don't understand the purpose behind different combinations of quotation marks in VBScript. Can you explain the use of quotation marks in the code segment that Listing 3, page 6, shows?

The key to understanding quotation marks in VBScript is learning two basic rules about VBScript strings. First, a VBScript string is simply a series of characters enclosed in quotation marks (" "). Second, to embed quotation marks (") inside a VBScript string (quotation marks you don't intend to mark the end of the string), you need to escape the quotation marks with an escape character. But the VBScript escape character is also the quotation mark, which is the cause of the confusion.

Let's look at a simple example, then compare the example with the string in Listing 3. The following script displays status information as it runs:

WScript.Echo "Update Registry: Success"

This statement simply echoes (i.e., displays) the string Update Registry: Success. Suppose you want to enhance the script by storing the status portion of the string in a separate variable rather than coding it into a string. One approach that you can use is

strStatus = "Success"
WScript.Echo "Update Registry:" & strStatus

So far, the snippet is fairly straightforward. You simply echo a string constructed from two substrings: the literal prefix ("Update Registry: ") concatenated with the value stored in the variable named strStatus. Figure 2 shows the result echoed to the screen. . . .


Already a VIP member?
Please log on to view the full article

Why become a VIP member?

VIP-only online access
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine

Subscribe Now
Reader Comments
I'm not even sure what the output is *SUPPOSED* to look like this article is so convoluted.

Greymulkin October 25, 2004 (Article Rating: )


This article is a waste of hard disk space.

Anonymous User March 01, 2005 (Article Rating: )


This solved my problem that VB help couldn't or any books I had.
Thanks.

Anonymous User March 09, 2005 (Article Rating: )


I think a simple example with an escape quote inside a single string should be placed before those concatenating variables. This confused me for a time, even though the article was really interesting.

Anonymous User March 25, 2005 (Article Rating: )


I think a simple example with an escape quote inside a single string should be placed before those concatenating variables. This confused me for a time, even though the article was really interesting.

Anonymous User March 25, 2005 (Article Rating: )


HERE IS AN EXAMPLE GUYS: strSQL = """This is a test"""
After re-reading it a couple of times I figured it out. I would have given your artical a 5 if I din't have to sift through the technical information.

Anonymous User June 14, 2005 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement