API Support Forum
OEC API > API Support > VB6 OnBarsReceived.
Author Topic: VB6 OnBarsReceived.
(4 messages, Page 1 of 1)
Moderators: VPfau
TKetcheson65
Posts: 2
Joined: Sep 30, 2016


Posted: Oct 04, 2016 @ 12:20 PM             Msg. 1 of 4
Have code largely ripped off from the excel example, now using it in a VB6 application. The "OECClass" module remains largely the same and works until I add an an OnBarsReceived Event. that looks like this:.

Private Sub c_OnBarsReceived(ByVal Subscription As OECAPICOM.ISubscription, ByVal bars As OECAPICOM.IBar)
MsgBox "....Handle bars received...."
End Sub

I get the following compile error:
“function or interface marked as restricted,or function uses an automation type not supported in Visual Basic”

Does this mean I can't use this function in VB6 or is there a different way of dealing with this?
VPfau
Moderator
Posts: 154
Joined:


Posted: Oct 05, 2016 @ 03:50 PM             Msg. 2 of 4
the signature looks like this:
Private Sub c_OnBarsReceived(ByVal Subscription As OECAPICOM.ISubscription, ByRef Bars() As OECAPICOM.IBar)

But unfortunately no, you cannot use this event. OnBarsReceived and OnHistoryReceived use an array in parameters. VBA does not work well with such COM events.

We let you know if we will have some solution for you.
Vitaliy Pfau
VPfau
Moderator
Posts: 154
Joined:


Posted: Oct 13, 2016 @ 04:20 PM             Msg. 3 of 4
We have added two new events: OnBarCollectionReceived and OnHistoryCollectionReceived which provides a collection parameter instead of array.
Please find new version here http://api.gainfutures.com/WebAPI/api/Files/DownloadClientUpdateLast?brandId=0&clientTypeId=5004&branchId=1
Example of using new events is here https://bitbucket.org/GainFuturesDev/comapisamples/raw/4675668bc5f6610ec1a847b5cd87cca9cb55f00d/Excel/Sample%20COM%20Book.xls
Vitaliy Pfau
TKetcheson65
Posts: 2
Joined: Sep 30, 2016


Posted: Oct 14, 2016 @ 10:29 AM             Msg. 4 of 4
Thanks much. This works very well as of this morning. Will incorporate in my program today.