?
Solved

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

Posted on 2008-06-21
9
Medium Priority
?
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

752 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