Olan,
As Herfried suggests: I normally write smaller methods to limit the scope of
variables in said methods.
In addition to the Using statement you can use a For or For Each statements
to introduce a new scope.
For index As Integer = 1 to 10
Next
For Each item As Whatever In whatevers
Next
NOTE: The Using statement should *not* be used to introduce a new scope,
rather it *should* be used to control unmanaged resources. Specifically it
is used to encapsulate a Try/Finally block around an object that implements
IDisposable! For example use a Using statement to ensure a file you are
reading is closed, or a Pen you are using is properly cleaned up.
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Olan Meier" <om@haps.comwrote in message
news:Ob**************@TK2MSFTNGP02.phx.gbl...
Hi,
I like to define scope in a method to ensure that variables donøt get used
more than once, and that things are nicely disposed. I use the
Using-keyword most of the time - but what do one use if theres no logical
way to do Using (you can't say Using tmp as string=""). I do a "If True -
End if" to make a scope - but thats stupid. Whats the right way to do it?
Thanks