-
July 22nd, 2008, 04:28 PM
#1
[RESOLVED] VB 6.0 Object Reference
Hello all, this is my first post on CodeGuru.
I am currently developing an ActiveX exe using VB 6.0. My plan calls for a private class (clsJournalBase) to be delcared and instanced once through sub Main() when the first exportable object is created.
I have two classes (clsJournal and clsJournalMaster both GlobalMultiUse) that can be exported through this exe; I am trying to get each object exported to create a reference to the single instance of clsJournalBase in the main module in order to have the exported objects react to events raised from clsJournalBase.
I know I cannot use the GetObject() function since I have created these classes in VB; and when I try to create my own function to pass the reference (written as a public function in main module), it creates a new instance in the two exported classes.
Is there a way to pass a reference back with out using GetObject()?
Any help would be appreciated. If some one has already posted a similar situation, please let me know or link to it.
Thank you in advance.
-
July 23rd, 2008, 01:03 AM
#2
Re: VB 6.0 Object Reference
Or is there another way to access the messages from clsJournalBase in my two exportable classes that will allow me to avoid setting up a property in each class as type clsJournalBase?
Finally, the ActiveX exe is going to be stored and run on a network server (Windows 2003 Small Business) while the client apps are run on client machines (Win XP SP2); I have tested event firing across the network and it has performed fine, I am just unsure if this would add any more complication to the structuring of my classes.
Here is a simplified version of the code.
clsJournalBase's code is really not important to this problem. Just keep in mind that the class contains events. Also keep in mind that the start up object is Sub Main().
Main Module
Code:
Private JournalBase as clsJournalBase
Public Sub Main()
set JournalBase = New clsJournalBase
End Sub
Public Function GetJournalBase() as clsJournalBase
set GetJournalBase = JournalBase
End Function
clsJournalMaster and clsJournal both have the following constructs.
Code:
Private WithEvents m_objJournalBase as clsJournalBase
Private Sub Class_Initialize()
set m_objJournalBase = MainModule.GetJournalBase()
End Sub
'Event Handlers for events raised in clsJournalBase.
Of course each of the classes has more code that does the actual processing for its tasks; this is the relavant code for how I reference the classes.
Last edited by VehementSoftware; July 25th, 2008 at 01:24 PM.
Reason: Adding Coding Example
-
July 25th, 2008, 04:24 PM
#3
Re: VB 6.0 Object Reference
Okay, apparently I am trying to create a Singleton Object. After doing some research, I have ordered a book "Advanced Visual Basic 6" and will post if the solutions work.
If anyone has any opinions about singletons, I'd love to hear them.
-
July 25th, 2008, 04:32 PM
#4
Re: VB 6.0 Object Reference
Why? I've never seen a purpose for them in a language that doesn't support inheritance. They might have a purpose in .NET, but VB6?
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
*Guarantee may not be honoured.
-
July 25th, 2008, 06:18 PM
#5
Re: VB 6.0 Object Reference
Ever think of searching for it? I found the article that i was thinking of in a few seconds.
http://www.vbforums.com/showthread.php?t=310205
-
July 25th, 2008, 06:19 PM
#6
Re: VB 6.0 Object Reference
The base class needs to modify system wide globally unique data. If there is a better way to do that, then I would love to hear it. This has been frustrating beyond all end.
-
July 25th, 2008, 06:22 PM
#7
Re: VB 6.0 Object Reference
Sorry dglienna, I just found out what the technique is called today. Had I known I would not have posted a thread; and since the thread was already started, I thought I would mention that I found the book.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|