following on from Gary's kind help and work for me on this thread (http://gruss-software.co.uk/forum/viewt ... highlight=)
I have used what he has shown me to create a process that will loop through each market (eg over / under 2.5) of each game (eg Liverpool Vs Chelsea) of each fixture list (eg Fixtures 13th August)
I've been testing it on Irish games (as the prem ones aren't developed yet)
Just though that it may be useful to anyone trying to do the same, or to see another COM example
(originally based on the test_BA_COM.xls file...)
- Code: Select all
Dim WithEvents ba As BettingAssistantCom.ComClass
Dim currentMarketId As String, marketUpdated As Boolean, fixtureIDx As Integer, marketIDx As Integer, matchIDx As Integer
Dim cont2 As Integer
Dim events As Variant
Dim x As Integer
Dim Matches As Variant
Dim Markets As Variant
Dim Leagues As Variant
Dim Fixtures As Variant
Dim Got_Extra As Boolean
Dim Finished As Boolean
Sub Get_Data()
Finished = False
fixtureIDx = 0
Sheets("Premiership").Cells.ClearContents
If ba Is Nothing Then
Set ba = New BettingAssistantCom.ComClass
End If
sports = ba.getSports()
For Each sport In sports
'Debug.Print sport.sport
If sport.sport = "Soccer" Then
events = ba.getEvents(sport.sportId)
For Each evnt In events
'Debug.Print evnt.eventname
If evnt.eventname = "Irish Soccer" Then
Leagues = ba.getEvents(evnt.eventID)
For Each league In Leagues
If league.eventname = "Airtricity Premier Division" Then
Fixtures = ba.getEvents(league.eventID)
For Each fixture In Fixtures
Debug.Print fixture.eventname
If Left(fixture.eventname, 8) = "Fixtures" Then
Matches = ba.getEvents(fixture.eventID)
For Each Match In Matches
matchIDx = 0
Markets = ba.getEvents(Match.eventID)
For Each market In Markets
cont2 = 5
marketIDx = 0
openNextMarket
Exit Sub
Next market
Next Match
End If
Next fixture
End If
Next league
End If
Next evnt
End If
Next sport
End Sub
Private Sub openNextMarket()
On Error GoTo 0
Dim found As Boolean
While marketIDx <= UBound(Markets) And Not found
found = True
currentMarketId = Markets(marketIDx).eventID
marketUpdated = False
Got_Extra = False
If marketIDx <= UBound(Markets) Then
Debug.Print "Opening market id:" & Markets(marketIDx).eventID & " - " & Matches(matchIDx).eventname & " : " & Matches(matchIDx).eventID&; " : " & Markets(marketIDx).eventname
result = ba.openMarket(Markets(marketIDx).eventID, Markets(marketIDx).exchangeId)
marketIDx = marketIDx + 1
If marketIDx = UBound(Markets) Then
GoTo Check_If_Last_Market_In_Game
Else
Exit Sub
End If
End If
marketIDx = marketIDx + 1
Wend
Check_If_Last_Market_In_Game:
If marketIDx > UBound(Markets) And matchIDx <> UBound(Matches) Then
' we have reached the last market (market.eventname), in that particular match (match.eventname) so
' we need to load up the markets array for the next match
'MsgBox markets(marketIDx).eventname
matchIDx = matchIDx + 1
On Error Resume Next
Markets = ba.getEvents(Matches(matchIDx).eventID)
For Each market In Markets
cont2 = cont2 + 5
marketIDx = 0
openNextMarket
Exit Sub
Next market
End If
If marketIDx = UBound(Markets) And matchIDx = UBound(Matches) Then
' we have reached the last market (market.eventname), in that particular match (match.eventname)
' in that fixture list - so
' we need to load up the matches and then markets array for the next fixture
'MsgBox markets(marketIDx).eventname
fixtureIDx = fixtureIDx + 1
matchIDx = 0
marketIDx = 0
On Error Resume Next
Matches = ba.getEvents(Fixtures(fixtureIDx).eventID)
Markets = ba.getEvents(Matches(matchIDx).eventID)
For Each market In Markets
cont2 = cont2 + 5
openNextMarket
Exit Sub
Next market
End If
End Sub
Private Sub ba_pricesUpdated()
If Not marketUpdated Then
prices = ba.getPrices()
If prices(0).marketId = currentMarketId Then ' - "Z1" holds acount of the jockeys
marketUpdated = True
x = 5
For Each priceItem In prices
With Worksheets("Premiership")
.Cells(cont2, 2).Value = [A1]
.Cells(cont2, 3).Value = priceItem.Selection
.Cells(cont2, 4).Value = Markets(marketIDx - 1).eventID ' market ID
.Cells(cont2, 5).Value = Sheets("Win Market").Range("Y" & x).Value ' -additional column - selection ID
x = x + 1
cont2 = cont2 + 1
End With
Next
openNextMarket
cont2 = cont2 + 1
End If
End If
End Sub
Private Sub CommandButton1_Click()
Get_Data
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 0
If Target.Columns.Count = 16 Then ' And Finished = False Then
If Sheets("Win Market").Range("Z1").Value = True And Got_Extra = False Then
Got_Extra = True
End If
If Sheets("Win Market").[N3] = currentMarketId And Got_Extra = True Then
ba_pricesUpdated
'openNextMarket
End If
End If
End Sub
Gary