Link to home
Start Free TrialLog in
Avatar of aaagarb
aaagarb

asked on

I want to limit the time an input box is presented...

I have a typical INPUT BOX FUNCTION. It brings up a question and sits waiting for input then the OK button. How can I control the time that the box is presented (I want about 5 seconds) before it the code moves on past it?
Avatar of Chizl
Chizl
Flag of United States of America image

Create your own InputBox and name the function InputBoxEx
Avatar of aaagarb
aaagarb

ASKER

Sorry, but your answer is confusing. I don't understand your intention.
Could you offer the code and explain yourself please?
This is e-mail, written by Karl E. Peterson

It's not really that tough.  Timers are only blocked in the IDE, and will continue to
work in an EXE.  Here's an example.  This works *if* compiled.  Fails otherwise.
Paste this code into a form with a timer and a command button.

Enjoy...   Karl


   Option Explicit
   Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
   Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd
As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
   Private Const WM_CLOSE = &H10
   Private Const MsgTitle As String = "Test Message"

   Private Sub Command1_Click()
      With Timer1
         .Interval = 2000
         .Enabled = True
      End With
      MsgBox "I should disappear in two seconds.", , MsgTitle
   End Sub

   Private Sub Timer1_Timer()
      Dim hWnd As Long
      Timer1.Enabled = False
      hWnd = FindWindow(vbNullString, MsgTitle)
      Call SendMessage(hWnd, WM_CLOSE, 0, ByVal 0&)
   End Sub

I think what Chizl is going for is this.  Create your own form that you will display as an input box.  The form will have a label for the prompt to the user, a text box or whatever you need for the users input, and an OK button.  You can also put on a timer control that you can use to limit the time that the input form is displayed.

When you display the form, fill the label with the appropriate prompt for the user, and on the form load, start the timer function that will kill the form after a set time.
Thanx jjmartin,
I thought that was pretty clear, but guess not.
Avatar of aaagarb

ASKER

ameba...this works perfectly if you use an information box. However, I am using an input box which does not go away until you press OK. Can you think of a way to modify your code to accomplish this with an input box.?

ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aaagarb

ASKER

works fine..thanks for persevering.

I think he was looking for someone to catch the fish for him not learn how to catch the fish for himself.
Nooo, MsgTitle was on a wrong place. It confused me, also.
No, I was talking about aaagarb or is ameba = aaagarb?  Both seem to be really confused.  MsgTitle being is the wrong place confused you and it's your code.
>really confused (RC)
OK. I can prove you everybody can be RC. See your e-mail box in a minute.
Mathmatics is a wonderful thing..  :)
Now that I know who you are..  
Avatar of aaagarb

ASKER

Not the forum for "can you top this?" wars.
Thanks both for your time and comments.