Re: VB6 DLL

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Jonathan" <Jonathan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:21207985-584F-4B0D-8FBB-6F914D8DDA5A@xxxxxxxxxxxxxxxx


'top of class module
Public WithEvents MSComm1 As MSComm

'initialize in startup routine
Set MSComm1 = New MSComm

Should the OnComm event still trigger in this class when data is recieived?
My code in the on_comm event is not processor intensive and contains lots of
doevents during processing. It mostly just sits there and waits.


An event handler would not normally need a DoEvents, it does not to be a loop.
It should handle the event and exit the handler. It will respond again when
there is more to do on the next On_Comm event.

As Ken said, the simplest way is to create a form, and put the timer and Comm
control on that. They need the form in order to hook into Windows messaging,
which is how they get their events.

(Ken, I think the form has to be loaded, though not shown, to get events, no?)

Private WithEvents MyMSComm As MSComm
Private WithEvents MyTimer As Timer

Set Frm = New Form1
Load Frm
Set MyMSComm = Frm.MSComm1
Set MyTimer = Frm.Timer1

At this point, you can now make settings on MyMSComm, call its procedures, and
receive its events, and set the properties of the Timer and receive its events.

You might then add a Progress event to your class, which you raise in every
On_Comm event, and some properties that a program can examine that show what is
going on at the moment.

Whether it is in a Dll or the Exe makes little difference, unless you might
distribute the Dll without the Exe for users who wanted to build their own
program around it.




.