Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript, purpose of colon?

Tags:

vbscript

What is the purpose of the colon?

e. g.:

Dim objConn : Set objConn = OpenConnection()` 

Is the colon used to combine the two statements into one line? I just want to be sure.

P.S.: I tried searching the answer to this question on Google with no luck.

like image 808
burnt1ce Avatar asked Jul 17 '09 18:07

burnt1ce


People also ask

What does colon mean in VBScript?

In VB style languages, including VBScript, the colon is an end of statement token. It allows you to place several statements on the same line.

What does colon mean in VB net?

In Visual Basic, the separator character is the colon ( : ). Use separators when you want to include multiple statements on a single line instead of separate lines. This saves space and improves the readability of your code.

How do I comment out a line in VBScript?

How do you comment code in VBScript? As shown in the syntax section, you can use an apostrophe ( ' ) instead of the Rem keyword. If the Rem keyword follows other statements on a line, it must be separated from the statements by a colon.

What is the purpose of the Set keyword in VBScript?

The SET keyword lets VBScript know that you are setting your variable equal to an object. In addition to this, you also have to set the variable equal to nothing after you are finished with it!


2 Answers

Yes, the code would work exactly the same on two lines; the colon's just a statement separator.

like image 139
Eifion Avatar answered Oct 10 '22 02:10

Eifion


You can put two (or more) lines of code in one line. It's most often used, as in your example, to declare and set a variable on one line.

Think of it like a semicolon in every other language, except optional.

like image 26
Matthew Groves Avatar answered Oct 10 '22 02:10

Matthew Groves