betplaced event

Please post any questions regarding the program here.

Moderator: 2020vision

betplaced event

Postby alrodopial » Fri Feb 24, 2023 5:36 pm

I think I asked this again few years back but memory doesn't help me ..
I want to place a bet using com's "placeBet" function and get the result later from a raised betPlaced event
so in a MODULE I have:
Code: Select all
Public ba As BettingAssistantCom.ComClass
Public Sub placeMyBet()
   
    ref = ba.placeBet(selecId, betType, odds, stake, False, token)
   
End Sub


where do I place the
"Dim WithEvents ba As BettingAssistantCom.ComClass"
or is it "Public WithEvents ba As BettingAssistantCom.ComClass"
or something else with "WithEvents"

I tried in "ThisWorkbook" but no event raised
I declare the ba once as public, on the top of one module
alrodopial
 
Posts: 1355
Joined: Wed Dec 06, 2006 9:59 pm

Re: betplaced event

Postby alrodopial » Fri Feb 24, 2023 8:55 pm

the bellow seems to be working:

in the "ThisWorkbook" object I placed the macro that will fire the bet and the macro that will capture the data from the raised event
Code: Select all
Dim WithEvents ba As BettingAssistantCom.ComClass

Private 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)
   
    Cells(10, 10) = ref
    Cells(10, 11) = selecId
    Cells(10, 12) = avgPriceMatched
    Cells(10, 13) = sizeMatched
    Cells(10, 14) = resultCode
    Cells(10, 15) = token

End Sub

Public Sub PlaceMyBet(sheetNumber, selectionID, askedBetType, askedOdds, askedStake, waitForEventToRaise, myToken, fillKillSecs)
   
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
    End If
    ba.TabIndex = sheetNumber - 1
   
    If fillKillDelay = Empty Then
        ref = ba.PlaceBet(selectionID, askedBetType, askedOdds, askedStake, waitForEventToBeRaised, myToken)
    Else
        ref = ba.PlaceBet(selectionID, askedBetType, askedOdds, askedStake, waitForEventToBeRaised, myToken, fillKillSecs)
    End If
   
End Sub


and I call it using the below code placed in a module:
Code: Select all
Sub testPlaceBetWithCom()
   
    sheetNumber = 1
    selectionID = 3
    askedBetType = "B"
    askedOdds = 90
    askedStake = 2
    waitForEventToRaise = False
    myToken = "234"
    fillKillSecs = Empty
   
    Call ThisWorkbook.PlaceMyBet(sheetNumber, selectionID, askedBetType, askedOdds, askedStake, waitForEventToRaise, myToken, fillKillSecs)
   
End Sub
alrodopial
 
Posts: 1355
Joined: Wed Dec 06, 2006 9:59 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 114 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.