Skip to main content

Inline With Statement (VB)

Inlines the object reference of this With statement into all dot-references.

#Purpose

By removing a With statement, you can make nested code context-independent. For rather small With statements, Inline With Statement (VB) can be used to unindent code and improve readability.

#Availability

Available from the context menu or via shortcuts:

  • when the edit cursor or caret is on a With statement. The caret should be on the With statement’s argument (an identifier).

#Example

Public Sub TestMethod()
    Dim objVar = New TestClassWith objVar
        .Prop1 = 10
        .Prop2 = 20
        .Prop3 = 30
    End With
End Sub

Result:

Public Sub TestMethod()
    Dim objVar = New TestClass
    objVar.Prop1 = 10
    objVar.Prop2 = 20
    objVar.Prop3 = 30
End Sub

#Screenshot

InlineWithStatement

See Also