Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 96
  • Last Modified:

vb.net syntax question

I ran into the following line of code in a project:
Dim X As System.Xml.XmlDocument : X = New System.Xml.XmlDocument()

what is the ":" being used for here?
0
dhenderson12
Asked:
dhenderson12
1 Solution
 
Trideep PatelCommented:
":" is used to write two statements in one line.
Like below

Dim i As Integer : Dim j As Integer : Dim k As Integer

Here once can write three separate lines
Dim i As Integer
Dim j As Integer
Dim k As Integer
0
 
Shaun KlineLead Software EngineerCommented:
The colon acts like a statement separator.
The code could be rewritten like below and produce the same effect:
Dim X As System.Xml.XmlDocument
X = New System.Xml.XmlDocument()

Open in new window

0
 
dhenderson12Author Commented:
thanks, guys.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
käµfm³d 👽Commented:
Personally, I just combine all of that into one statement--no colon needed:

Dim X As New System.Xml.XmlDocument()

Anything else is just a waste of keystrokes.
0
 
dhenderson12Author Commented:
sorry for the delay
0
 
dhenderson12Author Commented:
thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now