Solved

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

Posted on 2008-06-21
9
340 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
Independent Software Vendors: 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

730 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