Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can we nest With / End With blocks of code safely? 1

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
While going through someone elses code I found nested With / End Withs. Is this asking for trouble?

Steve
 
I have not had any problems with that. You could change it, but "if it ain't broke, don't fix it" may apply!

Learn from the mistakes of others. You won't live long enough to make all of them yourself.
 
From the MSDN Library:
MSDN said:
You can nest With statements by placing one With block within another. However, because members of outer With blocks are masked within the inner With blocks, you must provide a fully qualified object reference in an inner With block to any member of an object in an outer With block.

Note In general, it's recommended that you don't jump into or out of With blocks. If statements in a With block are executed, but either the With or End With statement is not executed, a temporary variable containing a reference to the object remains in memory until you exit the procedure.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top