Stack overflow in VBA

Please post any questions regarding the program here.

Moderator: 2020vision

Stack overflow in VBA

Postby dgs2001 » Fri Apr 13, 2007 8:45 am

Hi

Help please

How does a 'Stack Overflow' in excel occcur.
This is the latest error I'm getting

:? Frustration is setting in deep now I think I'm about ready to dump my sheets and try knitting denouncing gambling as the work of Satan in the process

George UK made a point about compiling my code then f8'ing through it in a seperate post, should a compile be done whenever you save or change code ??
If that is the case then this could be part of the problem.

Thanks in advance Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby PeteB » Fri Apr 13, 2007 8:56 am

Stack overflow - maybe you have coded an infinite loop? Or a bit of code recursively calls itself?

If you change code and then run it, it always compiles it first.

You may find it useful to use a version control system - I use Perforce (Subversion would be fine also) - every time you have something that works, submit it with a description - then if you break something you can always go back.
PeteB
 
Posts: 258
Joined: Tue May 23, 2006 12:13 pm

Postby GeorgeUK » Fri Apr 13, 2007 9:33 am

Agree with Pete. (Not encountered a stack error for years - sorry)

the stack will empty as the functions end, but if you have functions that don't end, the stack will continue to fill, getting bigger and finally run out of memory.

eg
sub one()
call two
end sub

sub two()
call one
end sub

macro 1 runs, calling macro 2, which calls 1, which calls 2, which calls...

this will create a stack error.

If you are trying to loop something, it may be that you need to reset something in your code so that when the loop starts again a value is reset to 0
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland

Postby dgs2001 » Fri Apr 13, 2007 1:27 pm

Anyone need a jumper ??

Maybe a nice knitted scarf ??

How about some knitted mitten NO NO NO STOP :shock: :oops:

I think the problem is that I have two worksheets with the same active race on and they both have Worksheet Calculate() subs which refer to each other and contain static variables so that would explain the loop thing and the stack filling with knit one pearl one.
I'm going to start again and ask for help when I get confused.

Thanks Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby GeorgeUK » Fri Apr 13, 2007 3:12 pm

Can't help it... got to ask...

Why do you have the same race being fed to 2 worksheets?
Just curious.

For those just starting coding.
What i used to do when i was going to start a programme:
- write what you are trying to achieve in pseudo code, possibly in steps.
1. login to racingpost
2. get racedata to excel
3. repeat step 2 every 5 seconds

- expand on the pseudocode and include it in the macro
(put ' before any text makes it a comment that won't affect the running of the macro. Use this to make notes or add comments)
1. login to racingpost
- ensure library references are set for internet explorer and html :oops:
- open ie
- goto racingpost login page
- enter login details
2. get racedata to excel
- go to results page
- put data into excel
3. repeat step 2 every 5 seconds
- goto 2
- Add some kind of way to stop update

If you do this, and put these details in as notes, then it's usually quite easy to see where you are going wrong if things don't work. Just break the problem down into smaller and smaller parts.
previously known as Gaseous (on the betfair forum)
User avatar
GeorgeUK
 
Posts: 315
Joined: Sat Nov 19, 2005 10:18 pm
Location: Scotland


Return to Help

Who is online

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