View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Trip[_3_] Trip[_3_] is offline
external usenet poster
 
Posts: 44
Default Creation & Implementation of VB6 DLL in VBA to raise events

Hello All,

I'm struggling a bit and would appreciate any direction anyone might be
able to provide...

I created the following simple ActiveX DLL in VB6, registered the DLL
in windows, and included the references in the two workbooks (described
below). This code resides in "Class1" of the DLL:
__________________________________________________ __
Public Event DataRecived(Price As String, MarketIndex As Byte)

Public Sub DateRec(Price As String, MarketIndex As Byte)

RaiseEvent DataRecived(Price, MarketIndex)
MsgBox "data received by DLL: " & Price & ", " & MarketIndex

End Sub
__________________________________________________ _

I then created a workbook to send data via the DLL. I placed the
following code in Sheet1..
__________________________________________________
Public WithEvents SendData As DataEvent.Class1

Sub DataSend()

Set SendData = New DataEvent.Class1
Call SendData.DateRec("12345", 1)
Set SendData = Nothing

End Sub
_________________________________________________

and I created a second workbook to receive the data. This code was
placed in Sheet1 of this workbook:
_______________________________________________
Public WithEvents ReceiveData As DataEvent.Class1

Sub initialize()

Set ReceiveData = New DataEvent.Class1

End Sub

Sub ReceiveData_DataRecived(Price As String, MarketIndex As Byte)

MsgBox Price & ", " & MarketIndex

End Sub
_______________________________________________

After initializing the the "ReceiveData" object in the "data receiving"
workbook, when I raise the event in the "data sending" workbook by
issuing the command:
Call SendData.DateRec("12345", 1)
the DLL manages to give me the shown msgbox, indicating that it is in
fact receiving the data. Yet, the second workbook does not respond to
the:
RaiseEvent DataRecived(Price, MarketIndex)
issued by the DLL. It is as though the event never fired.

Any ideas as to why??

TIA

Trip