Solved

vb.net syntax question

Posted on 2016-07-20
6
56 Views
Last Modified: 2016-08-09
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
Comment
Question by:dhenderson12
6 Comments
 
LVL 9

Expert Comment

by:Trideep Patel
ID: 41721050
":" 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
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 41721053
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
 

Author Comment

by:dhenderson12
ID: 41723040
thanks, guys.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 41725964
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
 

Author Comment

by:dhenderson12
ID: 41735108
sorry for the delay
0
 

Author Comment

by:dhenderson12
ID: 41747495
thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now