Solved

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

Posted on 2008-06-21
9
339 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 71
Access Object Property from VBA Module in Excel 2010 2 37
Visual Studio 2005 text editor 10 44
MS Access 03, TransferText, decimal places 8 78
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

856 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