dhruvpatel
dhruvpatel

Reputation: 1269

Can "with" keyword in VB.Net be used with multiple class objects

Is it possible to use With keyword with multiple class objects/controls in vb.net?

I can use it like:

With something
    .property = value
End With

But, is it possible to use it with multiple class objects?

Upvotes: 1

Views: 244

Answers (1)

suff trek
suff trek

Reputation: 39777

No, that's not possible, you can nest them, but that's about it:

With something1
    .property1 = value

     With something2
        .property2 = .property1 'something2.property2 = something1.property1
     End Width
End With

And it is really easy to get lost using this approach, especially if there're common properties between objects, so it is not recommended.

Upvotes: 1

Related Questions