Aren't you really just creating a single reference to an object, obj.
Doesn't the loop just reassign an object reference for GetSomeTypeOfObject()
to obj. You can't have more than one obj variable can you? I was surprised
that the dim inside the loop runs.
..
"Chris Dunaway" <"dunawayc[[at]_lunchmeat" wrote:
> On Tue, 26 Oct 2004 15:02:50 -0500, Chris wrote:
>
> > Is there any difference (memory/speed wise) between these two snipits. I
> > always like to write in snipit 2 style, but was just curious. I'm scared
> > I'd declare a thousand pointers when I don't need to.
> >
> > Snip 1:
> > Dim Obj as object
> > For ii as integer = 0 to 1000
> > Obj = GetSomeTypeOfObject()
> > DoSomeThingWithObject(Obj)
> > Next
> >
> > Snip 2:
> > For ii as integer = 0 to 1000
> > Dim Obj as object = GetSomeTypeOfObject()
> > DoSomeThingWithObject(Obj)
> > Next
> >
> > Thanks for the insite.
> > Chris
>
> As far as Dim'ing the object, you are still creating 1000 objects. In Snip
> 2, the Obj variable is only visible inside the For loop. Wheras with the
> first, the Object is visible after the for loop exits.
>
> --
> Chris
>
> dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
>
> To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
> replace certain words in my E-Mail address.
>
|