VBScript, purpose of colon?

隐身守侯 提交于 2021-02-05 20:53:56

问题


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.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/1144914/vbscript-purpose-of-colon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!