placeBet and betPlaced event problem

Please post any questions regarding the program here.

Moderator: 2020vision

placeBet and betPlaced event problem

Postby alrodopial » Mon Jul 31, 2017 6:10 pm

Hi,
I'm trying to place a bet using the com function "placeBet " asynchronous and get the bet details from the betPlaced event that will rise
The bet is fired ok ( matched, cancelled etc) but no betPlaced event rises
the code in a module is:
Code: Select all
Public ba As New BettingAssistantCom.ComClass

Sub testbet1()
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
        ba.tabIndex = 1
    Else
        ba.tabIndex = 1
    End If
               
    ba.placeBet 1, "B", 5, 2, False, "", 10
   
End Sub


and in sheet1 object is:
Code: Select all
Public WithEvents ba As BettingAssistantCom.ComClass

Public Sub ba_betPlaced(ByVal ref As String, ByVal selecId As Long, ByVal avgPriceMatched As Double, ByVal sizeMatched As Double, ByVal resultCode As String, ByVal token As String)
   
    ThisWorkbook.Sheets("Sheet2").Range("AA1") = selecId & "/" & avgPriceMatched & "/" & sizeMatched
    Debug.Print selecId & "/" & avgPriceMatched & "/" & sizeMatched
   
End Sub

I tried to change from public to Dim the events or place them in sheet2 but with no success
The "Sub ba_betPlaced(ByVal ref As String, By ...." is taken from Garrys' file "PlaceBet_Async.xlsm"

Garry/Mark/anyone ???
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: placeBet and betPlaced event problem

Postby alrodopial » Mon Jul 31, 2017 10:04 pm

ok, it is working if I move the macro testbet1 into sheet object , where the WithEvents and sub ba_betPlaced exists
I guess it will work with a function that will exists in sheet object and only fires the bet (with its data)(placeBet com function)
What if I want to keep the "ba.placeBet 1, "B", 5, 2, False, "", 10" inside the macro in my module where I have the rest of the code that checks the rules for firing the bet?
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: placeBet and betPlaced event problem

Postby alrodopial » Thu Aug 31, 2017 9:24 am

I want to use the com placeBet function for placing bets from sheet1, sheet2, sheet3 etc (macros from these sheets)
do I have to declare "Public WithEvents ba As BettingAssistantCom.ComClass" and also place the
Sub ba_betPlaced ( ......)
at every sheet1,sheet2 etc object?
Does this creates more than one instance of ba com? Can it be done?

or do I have to place them only in one sheet object and call only this one function from macros?

Anyone who uses the placeBet function knows?
There is no such info in the manual

Garry?
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: placeBet and betPlaced event problem

Postby MarkRussell » Thu Aug 31, 2017 10:12 am

Hi,

You need to set the tabIndex property prior to placing the bet.
It is a zero based index so tab page 1 use tabIndex=0 for the first tab page, tabIndex=1 for the second and so on.

Regards,
Mark
User avatar
MarkRussell
Site Admin
 
Posts: 1793
Joined: Tue Feb 20, 2007 6:38 pm
Location: Birmingham

Re: placeBet and betPlaced event problem

Postby alrodopial » Thu Aug 31, 2017 11:32 am

I know about the tab index
My code in the first post is setting it up
I wasn't asking this

I rephrase:

do I have to use ie the below code ONLY in sheet1: (some answers inside code)

Code: Select all
Public WithEvents ba As BettingAssistantCom.ComClass ' (or as New BettingAssistant.ComClass???)

Public Sub testbet1()
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
        ba.tabIndex =  ......... ' setting the correct number here
    Else
        ba.tabIndex = ......... ' setting the correct number here    End If
               
    ba.placeBet 1, "B", 5, 2, False, "", 10
   
End Sub

Public Sub ba_betPlaced(ByVal ref As String, ByVal selecId As Long, ByVal avgPriceMatched As Double, ByVal sizeMatched As Double, ByVal resultCode As String, ByVal token As String)
   
' back up bet details here
    ..........
   
End Sub

what will happen if bet details from two bets come at the same time, how many betPlaced events will be raised?


or should I use the same as previous code but inside sheet1 object AND inside sheet2 object AND inside etc
and call from macros ie :
Call sheet1.tesBet1 ( ' bet details here)
or
Call sheet3.tesBet1 ( ' bet details here)
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Re: placeBet and betPlaced event problem

Postby osknows » Thu Aug 31, 2017 2:36 pm

Take a look at this example https://www.dropbox.com/s/zbyl0jcezx44w ... .xlsm?dl=0

There is a ba object in Sheet1 which can be copied to multiple sheets if required.

Or there is classmodule which can be used as a single object and switch the tabIndex, or multiple instances can be created.

If multiple bets are in the placeBets then the event will fire multiple times.

Does that answer your question?

I don't know why a tab index is used though as surely it would be easier to just place bets via the marketId rather than what tab is selected.
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Re: placeBet and betPlaced event problem

Postby alrodopial » Thu Aug 31, 2017 5:15 pm

Thanks Os,
give me a couple of days and I'll be back, probably next week
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 52 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.