By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Timer Event

P: 1
Does anyone know how to create a timer on a form that allows a user to view a string of characters for a specified period of time (5 seconds or so) and then hide it?

I'm trying to add code to the click event of a button so either a label or text box appears and then hides after 5 seconds. I don't know where to even begin as I am quite new at this VBA programming.

Any suggestions?

Thanks in advance.
Mar 18 '08 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,597
Does anyone know how to create a timer on a form that allows a user to view a string of characters for a specified period of time (5 seconds or so) and then hide it?

I'm trying to add code to the click event of a button so either a label or text box appears and then hides after 5 seconds. I don't know where to even begin as I am quite new at this VBA programming.

Any suggestions?

Thanks in advance.
  1. Create a Text Box on your Form and name it txtTest.
  2. Create a Command Button on your Form and name it cmdTest.
  3. Make sure the Timer Interval Property of your Form = 0.
  4. Copy and Paste the following code to the Click() Event of cmdTest:
    Expand|Select|Wrap|Line Numbers
    1. Me![txtTest].Visible = True     'make Text Box invisible
    2. Me.TimerInterval = 5000         'set Timer Interval to 5 seconds
  5. Copy and Paste the following code to the Timer() Event of your Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Timer()
    2.   Me![txtTest].Visible = False      'make the Text Box invisible after 5 secs
    3.   Me.TimerInterval = 0              'disable the Timer
    4. End Sub
  6. When you click the Command Button (cmdTest), the Text Box and any text within it will be visible for 5 seconds then disappear. Clicking again on the Command Button will repeat the process.
  7. You can just as easily use a Label Controlo instead of a Text Box.
Mar 18 '08 #2

Post your reply

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