<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2722.900" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>What
is the Do Loop for, for the first example?</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>If you
are just using a class object, you only need to declare it when needed, and
destroy it when you are done with it.</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>The
exception to that rule, is that when you add a class to a collection, you need
to destroy it after you add it.....(before adding another that
is.)</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>For
example, let's say you have this as a class:</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Public
MyValue as Long</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2>Function DoSomething()</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>'Do
something with MyValue</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>End
Function</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>If you
wanted to have your class run through a for next loop, like
this:</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Dim
cls as MyClass</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Dim i
as Long</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Set
cls = New MyClass</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>For
i=1 to 100</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003> <FONT face=Arial
color=#0000ff size=2>cls.MyValue=i</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003> <FONT face=Arial
color=#0000ff size=2>cls.DoSomething</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Next
i</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Set
cls=Nothing</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>you
only need to create the class before the loop, and destroy it at the end,
because you can work with just one instance of that class, instead of creating
and destroying a new instance of the class for each loop.</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2>However, if you want to add a class to a collection:</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Dim
cls as MyClass</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003>dim col as Collection</SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Dim i
as Long</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Set
col= New Collection</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>For
i=1 to 100</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003> Set cls = New
MyClass</SPAN></DIV>
<DIV><SPAN class=300444022-06032003> <FONT face=Arial
color=#0000ff size=2>cls.MyValue=i</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003> col.Add cls</SPAN></DIV>
<DIV><SPAN class=300444022-06032003> Set cls =
Nothing</SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff size=2>Next
i</FONT></SPAN></DIV>
<DIV><SPAN class=300444022-06032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003>In the first example, putting the
creation/destruction of a class within the loop would just be a waste of
resources.....it would still work though. In this example, you are adding
a class to a collection, if you don't destroy the class after you add it, adding
it again would actual create a twin/clone of that instance. </SPAN></DIV>
<DIV><SPAN class=300444022-06032003></SPAN> </DIV>
<DIV><SPAN class=300444022-06032003>Drew</SPAN></DIV></FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> John W. Colby
[mailto:jcolby@colbyconsulting.com]<BR><B>Sent:</B> Thursday, March 06, 2003
4:15 PM<BR><B>To:</B> AccessD<BR><B>Subject:</B> [AccessD] FW: Class Module
Method in Loop<BR><BR></FONT></DIV>
<DIV><FONT face=Tahoma size=2><B>From:</B> Myke Myers
[mailto:mmmtbig@bellsouth.net] <BR><B>Sent:</B> Wednesday, March 05, 2003 5:38
PM<BR><B>To:</B> 'accessd-admin@databaseadvisors.com'<BR><B>Subject:</B> Class
Module Method in Loop<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=384463122-05032003>When I use a
method of a class module in a loop, where should 'Set=' be? Or should I be
using a standard module for this kind of method?</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=384463122-05032003>Dim obj as
clsTest</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=4><SPAN
class=384463122-05032003><STRONG>This:</STRONG></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=384463122-05032003>Set obj = new
clsTest</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003>Do</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=384463122-05032003>
obj.Method...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003>Loop</SPAN></FONT></DIV>
<DIV><SPAN class=384463122-05032003><FONT face=Arial size=2>Set obj =
nothing</FONT></SPAN></DIV>
<DIV><SPAN class=384463122-05032003></SPAN><SPAN
class=384463122-05032003><FONT face=Arial size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=384463122-05032003><FONT face=Arial size=4><STRONG>or
This:</STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=384463122-05032003><FONT size=4><FONT size=2><SPAN
class=384463122-05032003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=384463122-05032003>Do</SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=384463122-05032003>
<DIV><FONT face=Arial size=2><SPAN class=384463122-05032003>
Set obj = new clsTest</SPAN></FONT></DIV><FONT face=Arial>
obj.Method...</FONT></SPAN></FONT></DIV><SPAN class=384463122-05032003>
<DIV><SPAN class=384463122-05032003><FONT face=Arial size=2>
Set obj = nothing</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2>Loop</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2>T<SPAN
class=384463122-05032003>IA.</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN
class=384463122-05032003>Myke</SPAN></FONT></FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=384463122-05032003><FONT face=Arial
size=2></FONT></SPAN> </DIV></FONT></SPAN>
<DIV>
<HR>
</DIV>
<DIV>Is email taking over your day? Manage your time with eMailBoss. Try it
free! <A
href="http://www.eMailBoss.com">http://www.eMailBoss.com</A></DIV></BLOCKQUOTE></BODY></HTML>