For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > February 2005 > Standard Module lifespan









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Standard Module lifespan
David Clifford

2005-02-13, 9:01 pm

I have a quick question.
My project contains several standard modules, each module contains
procedures that are related. I understand that the entire module is only
activated when a procedure that it contains is called...hence my grouping of
related procedures. My question is, once the module has been opened, can I
close it again to release any resources that may be using?
My question is directed at one module in particular that holds references
for several OLE objects contained on reports, Word documents to be precise.
ie:

'In a standard module ( modDocuments.bas)

Public Function OLE_SomeDoc() As String

Dim Mystring As String
If ComputerName = "eric" Then
Mystring = App.Path & "\Documents\SomeName.Doc"
Else
Mystring = "Q:\ClientSystem\Documents\SomeName.Doc"
End If
OLE_SomeDoc= Mystring
Mystring = ""

End Function

When I have finished with the module, can I explicitly release resources by
setting the module to, say, Nothing?
I don't see any documentation on this, and, my gut says NO!

Thank you for your time

David Clifford


Duane Bozarth

2005-02-13, 9:01 pm

David Clifford wrote:
....
> When I have finished with the module, can I explicitly release resources by
> setting the module to, say, Nothing?

....

A module isn't an object, it's just an object file...so no.
David Clifford

2005-02-13, 9:01 pm

Thank you Duane..it's as I thought.

"Duane Bozarth" <dpbozarth@swko.dot.net> wrote in message
news:420FDDDD.DA024F6F@swko.dot.net...
> David Clifford wrote:
> ...
by[color=darkred]
> ...
>
> A module isn't an object, it's just an object file...so no.



Karl E. Peterson

2005-02-14, 4:06 pm

Hi David --

> My question is directed at one module in particular that holds
> references for several OLE objects contained on reports, Word
> documents to be precise. ie:

<snip>
> When I have finished with the module, can I explicitly release
> resources by setting the module to, say, Nothing?
> I don't see any documentation on this, and, my gut says NO!


Nope, as you guessed. Best suggestion, if you can't get this stuff into an object
with a defined lifetime, would be to write a helper routine that explicitly releases
them when you're through with 'em.

Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]


David Clifford wrote:
> I have a quick question.
> My project contains several standard modules, each module contains
> procedures that are related. I understand that the entire module is
> only activated when a procedure that it contains is called...hence my
> grouping of related procedures. My question is, once the module has
> been opened, can I close it again to release any resources that may
> be using?
> My question is directed at one module in particular that holds
> references for several OLE objects contained on reports, Word
> documents to be precise. ie:
>
> 'In a standard module ( modDocuments.bas)
>
> Public Function OLE_SomeDoc() As String
>
> Dim Mystring As String
> If ComputerName = "eric" Then
> Mystring = App.Path & "\Documents\SomeName.Doc"
> Else
> Mystring = "Q:\ClientSystem\Documents\SomeName.Doc"
> End If
> OLE_SomeDoc= Mystring
> Mystring = ""
>
> End Function
>
> When I have finished with the module, can I explicitly release
> resources by setting the module to, say, Nothing?
> I don't see any documentation on this, and, my gut says NO!
>
> Thank you for your time
>
> David Clifford




David Clifford

2005-02-15, 4:08 pm

Hello Karl..
Thanks for the suggestion, I was just thinking, as it happens, to write the
functions to a class module, that way, I could accomplish my aim.

Best regards.

David Clifford
"Karl E. Peterson" <karl@mvps.org> wrote in message
news:O3ePU%23rEFHA.4072@TK2MSFTNGP10.phx.gbl...
> Hi David --
>
> <snip>
>
> Nope, as you guessed. Best suggestion, if you can't get this stuff into

an object
> with a defined lifetime, would be to write a helper routine that

explicitly releases
> them when you're through with 'em.
>
> Later... Karl
> --
> [Microsoft Basic: 1976-2001, RIP]
>
>
> David Clifford wrote:
>
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com