|
-
Dec 11th, 2001, 12:08 PM
#1
Thread Starter
Addicted Member
Creating Objects
In my program, when the user presses a start button, I create an object of an activeX.dll. During the run of the program, the user is allowed to see a form or not see a form that is part of the dll. The problem is, I need to know how to determine if I have already created the object or not.
My code is something like this:
Set ObjServer = CreateObject("myproject.clsMyClass")
objServer.StartProgram
When the clien app is loaded, this above code does not occur unless they want to start the process. However, they can just choose another button which will show a form in that DLL. the code is this
if objserver has been set then
Objserver.ShowLogForm
Else
Set ObjServer = CreateObject("MyProject.clsMyClass")
ObjServer.ShowLogForm
end if
I need to know if the object was created yet?
-
Dec 11th, 2001, 12:16 PM
#2
Frenzied Member
Will this work?
VB Code:
If obj = Nothing Then
' CreateObject
Else
'it is already created
End if
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Dec 11th, 2001, 12:18 PM
#3
Bouncy Member
I'm not 100% about this but.......
I think if you use GetObject instead of CreateObject then it attempts to create an instance of an object that is already being used in memory (by any program), if this fails, then there is no instance of that object in memory so use CreateObject.
Thats the theory anyhoo.
darrel.
-
Dec 11th, 2001, 12:22 PM
#4
Thread Starter
Addicted Member
That works. I was trying to use if obj = nothing instead of if obj IS NOTHiNG.
Thanks alot.
M
-
Dec 11th, 2001, 12:24 PM
#5
darre1 - GetObject gets the latest instance of an object/class.
-
Dec 11th, 2001, 12:30 PM
#6
Bouncy Member
cander,
that's exactly what i just said, only i used more words, bad english, more sentences and lots of extra bits to exercise my fingers.
-
Dec 11th, 2001, 12:31 PM
#7
LOL
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
|