Skip to main content

Split With Statement (VB)

Splits this With statement into two; one nested inside the other.

#Availability

Available from the context menu or via shortcuts:

  • when the edit cursor or caret is on a With statement, provided that the argument is an expression that has a property or method reference.

#Notes

  • This refactoring splits the selected statement into two, by creating a nested With statement. The parent statement references the object, and the child references its property or method.

#Example

Public Sub getPersonData(ByVal PesronsObj As Persons, ByVal index As Integer)With PesronsObj.PersonsList(index)
        age = .GetAge()
        name = .GetName()
    End With
End Sub

Result:

Public Sub getPersonData(ByVal PesronsObj As Persons, ByVal index As Integer)
    With PesronsObj
        With .PersonsList(index)
            age = .GetAge()
            name = .GetName()
        End With
    End With
End Sub

#Screenshot

rsSplitWithStatementVB

See Also