With..End With Statements
Visual Basic provides an alternative way of invoking object members, the With..End With
statement. Consider the following code block, in which a new Person
class is instantiated and then properties are assigned while methods are invoked:
Dim p As New People.Personp.FirstName = "Alessandro"p.LastName = "Del Sole"Dim fullName As String = p.ToString
Using a With..End With
statement, you just need to specify the name of the class once and then type a dot so that IntelliSense shows members you can use, as follows:
Dim p As New People.PersonWith p .FirstName = "Alessandro" .LastName = "Del Sole" Dim fullName As String = .ToStringEnd With
There is no difference ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.