burnt1ce
burnt1ce

Reputation: 14897

VBScript, purpose of colon?

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.

Upvotes: 29

Views: 17721

Answers (4)

JaredPar
JaredPar

Reputation: 755041

Yes this is correct. 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.

Upvotes: 9

witttness
witttness

Reputation: 4994

What you have stated is correct. The purpose of the colon is to combine 2 otherwise separate lines into a single line. It works on most statements, but not all.

Upvotes: 6

Eifion
Eifion

Reputation: 5553

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

Upvotes: 23

Matthew Groves
Matthew Groves

Reputation: 26151

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.

Upvotes: 20

Related Questions