Problem with calling next market

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Problem with calling next market

Postby mariner1 » Tue Aug 12, 2008 10:47 am

I have a simple VB script that inserts -1 automatically when a race is suspended but it seems to call the next race at the same meeting rather than the next one in timed from the quick pick list.

Manually entering -1 seems to work fine however.

Would appreciate any input or help on this.
mariner1
 
Posts: 9
Joined: Thu Aug 07, 2008 7:11 am

Postby GaryRussell » Tue Aug 12, 2008 10:58 am

-1 is removed after it has been actioned so it's possible your VBA is inserting it multiple times. Each refresh triggers multiple Worksheet_Change events. You should set a flag to record that the next market has been triggered and not insert -1 if the flag is set. Clear the flag when it is detected that the market has changed. Do you want some sample code?
User avatar
GaryRussell
Site Admin
 
Posts: 9872
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby mariner1 » Tue Aug 12, 2008 11:28 am

GaryRussell wrote:-1 is removed after it has been actioned so it's possible your VBA is inserting it multiple times. Each refresh triggers multiple Worksheet_Change events. You should set a flag to record that the next market has been triggered and not insert -1 if the flag is set. Clear the flag when it is detected that the market has changed. Do you want some sample code?


Some sample code would be a great help Gary, thanks
mariner1
 
Posts: 9
Joined: Thu Aug 07, 2008 7:11 am

Postby GaryRussell » Tue Aug 12, 2008 5:05 pm

Here's an example of how it can be done. Insert the following code into the sheet1 module.

Code: Select all
Dim marketChanging As Boolean
Dim prevMarket As String

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Target.Columns.Count = 16 Then
        If Range("a1") <> prevMarket Then marketChanging = False
        prevMarket = Range("a1")
        If Range("f2") = "Suspended" And Not marketChanging Then
            marketChanging = True
            Range("q2") = -1
        End If
    End If
    Application.EnableEvents = True
End Sub
User avatar
GaryRussell
Site Admin
 
Posts: 9872
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby gizzard » Thu Sep 24, 2009 9:56 am

I'm having similar problems but I'm sure that it's my feeble VB skills.

I've tried some similar code to that provided but cannot get it to work.
What seems to happen for me is that the statement

If Range("a1") <> prevMarket Then marketChanging = False

is ALWAYS False because on each call of the subroutine prevMarket has been re-initialised to "" and doesn't keep the value of Range("A1")

How do I get it to keep the value of the previous market?
gizzard
 
Posts: 93
Joined: Wed Jun 10, 2009 12:45 pm

Postby Bid » Fri Sep 25, 2009 1:23 pm

You need to make sure that your declaration of the variable prevMarket is outside the function.

ie put it at the top of the module
Bid
 
Posts: 74
Joined: Mon Oct 15, 2007 10:58 am

Postby gizzard » Fri Sep 25, 2009 1:55 pm

Thanks, Bid. As I mentioned, I'm a VB novice but I'll give that a go.
gizzard
 
Posts: 93
Joined: Wed Jun 10, 2009 12:45 pm

Postby osknows » Fri Sep 25, 2009 6:31 pm

You should find everything you need here

http://gruss-software.co.uk/forum/viewtopic.php?t=3763
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am


Return to Discussion

Who is online

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