UserControl and CreateObject
russnewcomer_at_gmail.com
Date: 12/27/04
- Next message: Stefan Berglund: "Re: where is the Key in TreeView.NET?"
- Previous message: Rick Rothstein: "Re: MSDN isn't working now"
- Next in thread: emailstartsafterthisunderscore_russnewcomer_andendsafterthatone_at_gmail.com: "Re: UserControl and CreateObject"
- Reply: emailstartsafterthisunderscore_russnewcomer_andendsafterthatone_at_gmail.com: "Re: UserControl and CreateObject"
- Messages sorted by: [ date ] [ thread ]
Date: 27 Dec 2004 14:23:40 -0800
Greetings, group. I have been lurking for ~8 months now, and have
gotten a lot of valuable help from reading and searching the archives.
I have now come upon a problem that I cannot find described anywhere
else, and am wondering if anyone has any pointers that could help me.
I have a UserControl that encapsulates a MSCOMM object. It takes the
raw data from a Bluetooth-based barcode scanner that is aliased to a
COM port, validates the data, and then returns the information to a
form. This control is being used in an MDI project. So I can avoid
opening and closing the COM port throughout the project, I have been
using a globably defined variable (Public g_scanCtl as Object) to hold
the instance of the UserControl.
I have been using the line
Set g_scanCtl = CreateObject("LaserFab.Scanner")
inside Sub Main() to create an instance of the object. I was unable to
use the New keyword because I do not have any instance of the
UserControl on any of my forms inside the project.
Now, here is the kicker : I was doing some testing earlier today to
test situations where a computer does not have the Bluetooth scanner
connected, and commented out the Set g_scanCtl... line above. I
compiled a version, ran it on a test machine. After finishing my
testing, I removed the comment, and upon the next run of the project, I
was greeted with :
Run-Time error '429':
ActiveX Component Can't create object.
This error did not appear before I commented, compiled, and removed the
comment above.
Now, I was able to work around the problem by using the following line
(That I consider sub-optimal) in the stead of the CreateObject() call:
Set g_scanCtl = frmMain.Controls.Add("LaserFab.Scanner", "scn")
I also changed the declaration of g_scanCtl to Object instead of
Control, although I believe this change was probably superfluous to the
process, since it works either way.
But my question is, what did I do that caused this problem? (Can't
create Object) Did I somehow unregister my UserControl (which is part
of the LaserFab project)?
I consider my work-around suboptimal because I only want to create a
Scanner control if the user has a scanner attached to their machine,
and I was not keen on directly placing the control on my App, even
dynamically. Does this matter?
Thanks in advance for any help you may be able to provide.
Russ Newcomer
emailstartsafterthisunderscore_russnewcomer_andendsafterthatone@gmail.com
- Next message: Stefan Berglund: "Re: where is the Key in TreeView.NET?"
- Previous message: Rick Rothstein: "Re: MSDN isn't working now"
- Next in thread: emailstartsafterthisunderscore_russnewcomer_andendsafterthatone_at_gmail.com: "Re: UserControl and CreateObject"
- Reply: emailstartsafterthisunderscore_russnewcomer_andendsafterthatone_at_gmail.com: "Re: UserControl and CreateObject"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|