Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when variables start with a dot/period in vb.net?

Some of the parameters in this call for example:

 ConnectToDatabase(oCustomPropReader.ConnectionType, .ConnectString, _
           oCustomPropReader.SystemMdb, .UserName, .Password)

Why do UsernName, Password, and ConnectString have dots before them? Thanks!

like image 571
Mike Canner Avatar asked Aug 26 '14 13:08

Mike Canner


1 Answers

These are properties (or methods) of an object declared as With (See the docs for more info.)

Consider the following:

 Dim obj As New Object
 obj.Username = "foo"
 obj.Password = "bar"

this is the same as the following:

 Dim obj As New Object
 With obj
       .Username = "foo"
       .Password = "bar"
 End With

They can reduce the amount of characters you have to type if you are reading or writing a lot of properties within the same object.

It can also improve readability if you have a long object name.

Note that that code you are looking at may have the With and End With off the currently viewable page so it is not obvious what these properties refer to.

like image 142
Matt Wilko Avatar answered Oct 21 '22 11:10

Matt Wilko