Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-21
9
Medium Priority
?
346 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…
Suggested Courses

610 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