|
-
July 10th, 2001, 09:02 AM
#1
Error creating an object
Hi. I am a VC++ developer. This is the first time I'm using VB. I have a COM component which is not a control, that fires an event. In VB I want to catch this event so I created an object using WithEvents. I then do a new on the object but it's here that it complains when I run the app.
The code follows:
option Explicit
private withevents mEvent as MsgGrabber
private Sub Form_Load()
set mEvent = new MsgGrabber
End Sub
private Sub mEvent_MessageRetreived(byval bstr as string)
MsgBox "This is the string: " + bstr
End Sub
private Sub Send_Click()
mEvent.SendMessage ("Client string")
End Sub
MsgGrabber is my COM interface's implementation. The compiler complains on the Set statement. The error I get is:
Automation Error
The specified module could not be found.
Any help would be appreciated.
-
July 10th, 2001, 10:13 AM
#2
Re: Error creating an object
I think you want to change your declaration to
private withevents mEvent as new MsgGrabber
then drop the set statement. Then your sendmessage should work OK. Also make sure your COM object is registered of course. To do it the way you have it take a look at GetObject. Sometimes you don't want to use new in your declaration if there's a chance that you won't actually need the object in the life of the app.
Also, place a...
set mEvent = nothing
in your form unload
CodeHacker
Rate me if it helped, Thanks
-
July 10th, 2001, 10:23 AM
#3
Re: Error creating an object
You can't use the keyword new in the same line as withevents. Causes a compile error.
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
|