I am comparing picture names in a Folder with the names in a table, in order to find files that are not referenced within the database. I call these "Orphans"
This routine is imbedded in a large program, and I am only presenting a small fraction of the code. All variables are declared. Those beginning with str... are String, beginning with ii... are Long, lbl... are Labels, etc.
The routine worked, but the image flickered because line 22 of the code is executed ~80K times. To reduce the flicker, I inserted the lines marked as "Added line". The code still works, but the label on the form (lblDisplay) isn't displayed until cmdFindOrphans_Click exits. As a matter of fact, the timer event appears not to be triggered, as the function (code lines 28-30) is never executed.
A toggle breakpoint at line 25 has TimerInterval = 250, as it should. Before you ask, yes, the property sheet for the form has [Event Procedure], and the [. . .] gets me to the code corresponding to line 28.
Is there something I am missing here? -
Private Sub Form_Load()
-
. . . .
-
Me.TimerInterval = 0 'Added line
-
End Sub
-
-
cmdFindOrphans_Click
-
iiRecCt = 0
-
iiOrphanCt = 0
-
lblDisplay.Caption = ""
-
Set dbs = CurrentDb
-
Set rst = dbs.OpenRecordset("SELECT . . .")
-
-
strFile = Dir(strPath & "\*.*")
-
Me.TimerInterval = 250 'Added line
-
Do Until strFile = ""
-
iiRecCt = iiRecCt + 1
-
If IsOrphan(arg1, . . .) = True Then
-
iiOrphanCt = iiOrphanCt + 1
-
. . . .
-
End If
-
lblDisplay.Caption = "Checked=" & iiRecCt & " Orphans=" & iiOrphanCt
-
'Me.Repaint 'Original line
-
strFile = Dir()
-
Loop
-
Me.TimerInterval = 0 'Added line
-
End Sub
-
-
Private Sub Form_Timer() 'Added line
-
Me.Repaint 'Added line
-
End Sub 'Added line
-
OldBirdman
6 4197
I've frequently seen the use of the Timer given as the cause of screen flicker, but I've never heard of it being used to suppress screen flicker! The problem here, I expect, for the label not appearing, is that you're repainting the screen too frequently. Timer Interval = 1000/second, so an Interval of 250 means the screens repainting every 1/4 of a second.
Linq ;0)>
I could have no label, and no counters. The problem would go away. I would have to substitute the 'hourglass' for the cursor, to show I was actually doing something, and not just looping or idle.
I had flicker when I did not have the timer. I checked 4,000 files in about 9 seconds, so the repaint rate would have been about 400/second, somewhat faster than 4/second.
I could live with the flicker, but I felt that the repaint might be quite expensive, and reducing the number of times by a factor of 100 might speed it up.
OldBirdman
Hi, OldBirdman.
To the best of my knowledge events (including that from form timer) are not asynchronous in VBA. No timer event will be fired while code is running.
You may try to use win timer but this maybe a bit unsafe.
Regards,
Fish
Hi, OldBirdman.
To the best of my knowledge events (including that from form timer) are not asynchronous in VBA. No timer event will be fired while code is running.
You may try to use win timer but this maybe a bit unsafe.
Regards,
Fish
I do believe that FishVal is right on this one, as long as code execution is contained within the Do...Loop, the Timer() Event will never fire.
Thank you! Not sure what "asynchronous" is, but that's OK.
Within my loop, I inserted an iiCounter and incremented for each iteration of the loop. Then: -
. . .
-
If iiCounter mod 1000 = 0 then
-
lblStatus.Caption = "Checked=" & iiCounter & " --- Found=" & iiFound 'Checked=3000 --- Found=8'
-
Me.Repaint
-
End If
-
. . .
-
I can adjust the speed of the display update by tinkering with the 'mod' value. I consider this problem solved. Thank you all again.
OldBirdman
Not a problem.
Good luck.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael |
last post by:
Here is my problem:
I have a MDI application and when I load my child forms I get alot of
flicker.
I have tried to implement double buffering :
Public Sub New()
MyBase.New()
'This call is...
|
by: Marek Mänd |
last post by:
This seems an IE issue only:
4253 bytes testcase:
http://www.hot.ee/idaliiga/testcases/ieselect/bnlinkingselectinmsie.htm
Can one have
1) a mouseover/mouseout element on TBODY
2) change in...
|
by: Christopher Weaver |
last post by:
I've used a Time.Tick event to do this:
pictureBox1.Location = new Point(PictureLeft, 0);
The speed with which the change takes place increases as I reduce the value
of Timer.Interval until it...
|
by: karunakar |
last post by:
Hi All
I dont want to expire the applicatoion
Once login the application i dont want to expire the application
Presently iam doing using cookies this is not working fine
Please help me out
...
|
by: Per Dunberg |
last post by:
Hi all,
I have to develop a "skinned" application and I have a problem with the
graphics.
When a form is loaded and displayed there's aways a flicker where all the
controls are located on the...
|
by: Peter Row |
last post by:
Hi,
I've started work on my own control some parts of which use standard
controls, others I need to draw on my controls surface to get the display
output I require, however....
I seem to be...
|
by: Wayne |
last post by:
I've noticed some screen flicker when using Access 2003 under Vista
and I'm curious as to whether this is a bug or peculiar to my machine.
In design view, if I make changes to a form and then...
|
by: Frank Rizzo |
last post by:
Hello, I inherited a large Winforms project that is suffering from
excessive flicker when switching between portions of the application.
I've noticed that most parts of the application (user...
|
by: =?Utf-8?B?TWlrZTk5MDA=?= |
last post by:
Hello,
I am wondering if it is a good idea to use GC.Collect() in a timer. For
example, timer is fired every 5 minutes and calls GC.Collect().
In our server app the memory goes to 600MB and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |