With..End With
statement
Visual Basic provides an alternative way for invoking object members that is 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:
Using a With..End With
statement you just need to specify the name of the class once and then simply type a dot so that IntelliSense shows up members that you can use, as follows:
There is no difference between the two coding techniques, so feel free to use the one you like most. ...
Get Visual Basic® 2010 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.