VBA "negative" time

Please post any questions regarding the program here.

Moderator: 2020vision

VBA "negative" time

Postby nerobot » Fri Jul 09, 2010 2:49 pm

Hi,

I'm trying to write something into excel VBA that will close all bets when the time (the time before the market begins, as shown on BA) gets to zero. To do this I've created a double value to store the time. This works fine while the time shown is positive, but when the time is negative, the program crashes.

My question is: How can I represent negative time in VBA that will allow me to perform simple calculations and comparisons.

Regards,

Steven
nerobot
 
Posts: 15
Joined: Mon Dec 07, 2009 3:23 pm

Postby GaryRussell » Fri Jul 09, 2010 2:53 pm

Here is some code from a sample spreadsheet that does this calculation. timeFromStart is of type "Date"
Code: Select all
        If Left([D2], 1) = "-" Then
            timeFromStart = Mid([D2], 2)
            beforeStart = False
        Else
            timeFromStart = [D2]
            beforeStart = True
        End If
        secondsFromStart = (Hour(timeFromStart) * 3600) + (Minute(timeFromStart) * 60) + Second(timeFromStart)
        If Not beforeStart Then secondsFromStart = -secondsFromStart
User avatar
GaryRussell
Site Admin
 
Posts: 9872
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby nerobot » Fri Jul 09, 2010 3:10 pm

Once again thank you. Exactly what I was looking for.

Regards,

Steven
nerobot
 
Posts: 15
Joined: Mon Dec 07, 2009 3:23 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 35 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.