Solved

Why does my timer cause run time error 7 out of memory and other glitches

Posted on 2008-06-21
9
336 Views
Last Modified: 2010-04-30
Hi

I have a timer in my app which works fine with it's function but it is causing other major errors. A|fter the app has been running foe a while I get runtime error message 7 out of memory and other glitches as a result. Anyone any experience of this.

This is my timer code, it looks to see if an image is open if it is not it runs several commands if an image is open it does nothing.
Dim endTime As Double

endTime = frm_toolbar.Timer1 + 1000
 
 

Do While frm_toolbar.Timer1 < endTime And exitloop = False

' Debug.Print Now & vbCrLf

DoEvents

 Call set_load_buttons

 Call check_image_source

Loop

frm_toolbar.Timer1.Interval = 0

frm_toolbar.Timer1.Enabled = False

Open in new window

0
Comment
Question by:eneate
  • 4
  • 4
9 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 21837496
Is this code in the Timer event - Sub Timer1_Timer()?

It seems to be an unconventional use of the timer.
0
 

Author Comment

by:eneate
ID: 21837562
yes
0
 

Author Comment

by:eneate
ID: 21837709
how could I make it more conventional? It was worded this way as I had problems getting the app to unload completly. The problems are very random it can work for ages with no problems I can't find any consistancy at the moment.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 21837937
What are you trying to do?. The usual way is to set the timer interval, and put whatever you want to achieve after the delay in the event
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 21837944
Sorry, clicked in the wrong place.
What are you trying to do?. The usual way is to set the timer interval, and put whatever you want to achieve after the delay in the event
'code to start timer

frm_toolbar.Timer1.Interval = 1000

frm_toolbar.Timer1.Enabled = True

 

 

Private Sub Timer1_Timer()

    Call set_load_buttons

    Call check_image_source

    frm_toolbar.Timer1.Enabled = False

End Sub

Open in new window

0
 

Author Comment

by:eneate
ID: 21838115
Hi, thanks

I've tried that now it doesn't do anything. The idea is that this runs continually through the aplication looking to see if an image is open. If an image is not open the timer kicks in and changes the settings hence the loop in the original code but I think this is causing the memory problem
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 21838125
I think you need the timer to prevent a check loop eating up CPU time, so that it only checks once a second, say.
'code to start timer

frm_toolbar.Timer1.Interval = 1000

frm_toolbar.Timer1.Enabled = True

 

 

Private Sub Timer1_Timer()

   If Not ImageOpen() then

         ChangeSettings

   Endif

End Sub

Open in new window

0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 21839483
>> Call set_load_buttons
>> Call check_image_source

The problem could exist in those methods as well.
0
 

Author Closing Comment

by:eneate
ID: 31470589
Hi
Thanks for the feedback, removing the loop and at times disablingt the timer and reenabling it appears to have solved the problem. Thanks again
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now