Taking Advantage of VBScript’s Colon

To save space in a script, you can take advantage of VBScript’s vastly under-used colon. The colon lets you join two lines of code.

1 Min Read
ITPro Today logo in a gray background | ITPro Today

To save space in a script, you can use VBScript's colon (:) to join two lines of code. Using a colon tells Windows Script Host (WSH) to treat the code that follows as if it were a new line. For example, you can join these two lines of code

Dim strUrgentstrUrgent = "This variable contains my urgent text string."

by inserting a colon between them:

Dim strUrgent : strUrgent = "This variable contains my urgent text string."

You aren't limited to using the colon to join variables with their declarations. You can use the colon to join any two lines of code. You just need to put a space before and after the colon.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like