Create With Statement (VB)
In This Article
Creates a With statement for the specified object within the selection.
#Purpose
By introducing a With keyword, you can make embedded code more compact and more readable.
#Availability
Available from the context menu or via shortcuts:
- when the selection is on a code block that has references to properties of the same complex type.
Note
This refactoring is available only in Visual Basic.
#Example
Public Sub TestMethod()
Dim objVar = New TestClass
objVar.Prop1 = 10
objVar.Prop2 = 20
objVar.Prop3 = 30
End Function
Result:
Public Sub TestMethod()
Dim objVar = New TestClass
With objVar
.Prop1 = 10
.Prop2 = 20
.Prop3 = 30
End With
End Function
#Screenshot
See Also