events - COM object in VB 6: user-defined type not defined -


in vb6 project have added reference com dll: c:\windows\system32\locationapi.dll

the following code works , object's methods/properties can accessed correctly:

public civicfactory set civicfactory = createobject("locationdisp.civicaddressreportfactory") 

however, events don't work - cannot catch them. guess need declare object this:

public withevents civicfactory locationdisp.civicaddressreportfactory 

but gives me error "user-defined type not defined" @ line.

can tell me why says while first code works well?

and purpose event handlers working, can point out error or missing in code:

public civicfactory private sub civicfactory_newcivicaddressreport(report)     msgbox "new civic address report arrived"     displaycivic (report) end sub set civicfactory = createobject("locationdisp.civicaddressreportfactory") civicfactory.listenforreports (1000) 

similar code works in vbscript, cannot working in vb 6 - event handler never gets called.

thanks in advance!

i don't develop on windows 7 can't test it, think need implement ilocationevents interface , create instance of class , pass registerforreport method of ilocation interface of civicaddressreportfactory object.

in other words did not bother implement events @ all, instead com callbacks, a.k.a. "script events."

this doable, , required use lot of new com libraries since put squint on vb6 , other activex hosts. example have goofy things use upnp libraries in xp , later, async requests using msxml helper objects, etc.

reprehensible, true enough. expect microsoft.net?

think of competitive advantage once worked out. that's do.


Comments