Solved

vb.net syntax question

Posted on 2016-07-20
6
88 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 75

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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