473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Timing an Image in Forms

8
How do I make the image pause for 2 seconds and then hide in the for? The code I used was as follows:-
Expand|Select|Wrap|Line Numbers
  1. If Image6.Visible = True Then
  2. PauseTime = 2 ' = 2 seconds
  3. Start = Timer
  4. Do While Timer < Start + PauseTime
  5. Exit_Pause:
  6. Exit Function
  7. End If
  8.  
Thanks a lot in advance.

hide it in the form*?

Even the following code is not working:-

Expand|Select|Wrap|Line Numbers
  1. If Image6.Visible = True Then
  2. pause = 1
  3. Image6.Visible = False
  4.  
  5. End If
Jan 1 '13 #1
9 2373
zmbd
5,501 Expert Mod 4TB
Please do not bump your threads; this is against the site policy. Please keep in mind that moderators, experts, and others are un-paid volunteers that attempt to provide some help and guidance in-between our obligations to work and family. Please be patient – especially on holidays and busy posting days.

Please keep in mind: Bytes is not a code writing nor homework service. Please read the FAQ and posting guidlines before reposting your question.

By, simply stating that your code "doesn't work," posting a generic/jargon filled error along with code that appears to have had very little if any troubleshooting performed, and expecting someone to help doesn't usually result in much of an answer and may result in your thread being deleted. Instead, please tell us what you were expecting to happen, what actually happened, for each error: the EXACT title, error number, and descriptions that occurred and at what line in your posted code the error occurred. These are the minimum requirements for posting a question of this nature.

Very first thing, at the VERY top of all of your code modules make sure these lines are present:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
Then do a debug compile in the VBA-Editor.
Fix your errors.
Repeat the debug and fix until you have no errors.

Next... what is "timer" on line 3 of code block 1?
I can only assume that you are attempting a call to the timer-function... in which case I suggest that you select that word in your VBA-Editor and press [F1]

Your second code block is, and I don't know how to state this kindly, garbage.
Jan 1 '13 #2
NeoPa
32,556 Expert Mod 16PB
It's not clear exactly what you want as you left all your typos in your post and what's there doesn't make a whole lot of sense. What you want can be handled using the Timer. Of that I'm reasonably certain. Setting the value of the picture contol's .Visible property to True and False alternately is also part of the solution. Exactly what, when and where depends largely on the details which are not, so far, found in the question.
Jan 1 '13 #3
sg123
8
Hi NeoPa
I want the image to appear when I click the appropriate command button, stay on-screen for 5 seconds and then disappear. Thanks for your advice.
Jan 4 '13 #4
NeoPa
32,556 Expert Mod 16PB
Thank you. That is much clearer.

What you need to do is :
  1. Design the form with a Form_Timer() procedure in the module and a value for .TimerInterval of 5000.
  2. Set the .Visible property of the image to True in the Form_Open() procedure.
  3. In the Form_Timer() procedure set the .Visible property of the image to False then set Me.TimerInterval to 0.

That should do what you require. When you've got it working, look at what you've done and see if you can understand how and why it works ;-)
Jan 4 '13 #5
ADezii
8,834 Expert 8TB
If the only criteria is what you stated in Post #4, namely:
I want the image to appear when I click the appropriate command button, stay on-screen for 5 seconds and then disappear,
then there is a much simpler solution bypassing the Form's Timer() Event which I feel is not appropriate in this case.
  1. Set the Visible Property of the Image Control (Image6) to No either in Form Design View or prior to the Form displaying any of its Controls.
  2. Copy-N-Paste the following Code into the Click() Event of a Command Button.
    Expand|Select|Wrap|Line Numbers
    1. Dim PauseTime, Start
    2.  
    3. PauseTime = 5
    4.  
    5. Start = Timer
    6.  
    7. With Me![Image6]
    8.   .Visible = True
    9.  
    10.   Do While Timer < Start + PauseTime
    11.    DoEvents
    12.   Loop
    13.  
    14.   .Visible = False
    15. End With
    16.  
Jan 5 '13 #6
NeoPa
32,556 Expert Mod 16PB
ADezii, You seem to be under the impression that looping through code for 5 seconds is a better solution than using the Timer approach. I cannot conceive of why that might be, but I'm open to hearing your reasoning on that.

My understanding would be that using a Timer based approach is infinitely better as it enables one to avoid the clumsiness of code looping. On the other hand, if you must loop through code, then including a DoEvents statement is certainly the way to go about it.

PS. When dealing with Timer() you need to allow for the fact that 23:59:57 will never result in a value that is 5 seconds on. It is more reliable to deal with the return value of Now(), which deals in values of days. Minutes are in increments of 1 / (24 * 60).
Jan 5 '13 #7
ADezii
8,834 Expert 8TB
The Logic behind a Form's Timer() Event is to allow periodic/scheduled execution of a Macro or piece of Code automatically at set intervals. This is something that would involve a timed Database Event. I do not see a 1-Time display of a Graphic Image for a period of 5 seconds as falling into this category. I honestly feel that the use of the Timer() Event, in this specific scenario, is counter intuitive.
Jan 5 '13 #8
NeoPa
32,556 Expert Mod 16PB
ADezii:
The Logic behind a Form's Timer() Event is to allow periodic/scheduled execution of a Macro or piece of Code automatically at set intervals.
I don't believe that's correct. A timer event is there for any time related or scheduled job. This can be a one-off just as much as a repeating job.

The idea of code tying up the processor (albeit less completely with the DoEvents calls), just doesn't make sense to me when compared with the opportunity to let the system call you as and when the time period has expired. This is very similar to the situation where the choice was between polling a status and allowing an interrupt to trigger the code that needs to run. The interrupt approach was always preferred due to the lack of negative side-effects. I cannot see that the same issues are not involved here.

The timer call is based on a chip that maintains the time and works outside of the sequence of instructions processed by the main processor. Thus, the main flow of the processor is only involved exactly when necessary. Continually polling the state of the time, on the other hand, ties the processor up very heavily to do a similar job. I find it very hard to understand why the latter would ever be preferred to the former.
Jan 5 '13 #9
sg123
8
Thanks to both of you....my problem is solved :)
Jan 7 '13 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: S. David Rose | last post by:
Hello All! I am new to Python, and wanted to know if I might ask you a question regarding timing. I want a main loop which takes photos from 8 different web-cams, each can be addressed by...
10
by: Andy B | last post by:
Hi, I am very new to JavaScript and my first assignment is to create a simple game. Below is my code which works fine in IE, but not in any other browser (Opera, Netscape, Mozilla). It has no form...
3
by: pbbriggs | last post by:
I will try to be as descriptive as possible, but this error has me stumped and I am not sure what relevant info to include.... I am running Access XP on a Windows XP machine. I initially began...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
1
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox...
7
by: jamie | last post by:
hey all, I am attempting to do motion control for a final project, but I have a concern.... For motion control, timing is everyting, the better it is, the better it works. Currently I am...
1
by: AVance | last post by:
Hi, I've come across this scenario in ASP.NET 1.1 with forms authentication where the forms auth doesn't seem to timeout correctly, nor redirect to the login page. I have done some testing, and...
0
by: Paul W | last post by:
Hi - I have an app that does not use sessions: <sessionState mode="Off" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"...
0
by: Daniel Fetchinson | last post by:
On 4/15/08, Daniel Fetchinson <fetchinson@googlemail.comwrote: BTW, using the following ###################################################################### # CODE TO TEST BOTH...
2
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I'm trying to create a QRCode decoder in PHP. I'm not sure if something like this has been created already, but from my searching, I don't think it has. If you don't know what QRCodes are, they're...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.