[dba-VB] VB6: Object Reference

Brett Barabash BBarabash at TappeConstruction.com
Fri Apr 18 09:07:28 CDT 2003


Here's one that is stumping me:
I want to write an ActiveX DLL that contains: 
- A class module to handle all properties/methods/events.
- A form that is instantiated by the class, to display visual information to
the user.

The form needs to interact with the class module to get at its
properties/methods/events, so I thought that I should store an object
reference in the form.  I tried the following code in the form:

Private WithEvents mobjSrcObj As clsMyClass

Public Property Set SourceObject (objSrcObj As clsMyClass)
    Set mobjSrcObj = objSrcObj
End Property

In the class module, I have the following code:

Private mfrmMyForm As frmMyForm

Public Sub Class_Initialize
    Set mfrmMyForm = New frmMyForm
    Set mfrmMyForm.SourceObject = Me
End Sub

This works great, except for one small thing.  I cannot destroy the class
instance by setting it to Nothing, because the Form it instantiated still
has a reference to it.

There has to be a simple solution to this!

Brett Barabash, MCP 
Tappe Construction, Co. 
Eagan, MN 
bbarabash at tappeconstruction.com 
(651) 256-6831 
"Computer games don't affect kids; I mean if Pac-Man affected us as kids,
we'd all be running around in darkened rooms, munching magic pills and
listening to repetitive electronic music." - Kristian Wilson, Nintendo,
Inc., 1989.

--------------------------------------------------------------------------------------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this email in error please notify the
originator of the message. This footer also confirms that this
email message has been scanned for the presence of computer viruses.

Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Tappe Construction Co.

Scanning of this message and addition of this footer is performed
by SurfControl E-mail Filter software in conjunction with 
virus detection software.



More information about the dba-VB mailing list