Solved

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

Posted on 1998-12-16
15
149 Views
Last Modified: 2010-05-03
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?
0
Comment
Question by:aaagarb
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 4

Expert Comment

by:Chizl
ID: 1450782
Create your own InputBox and name the function InputBoxEx
0
 

Author Comment

by:aaagarb
ID: 1450783
Sorry, but your answer is confusing. I don't understand your intention.
Could you offer the code and explain yourself please?
0
 
LVL 15

Expert Comment

by:ameba
ID: 1450784
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

0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1450785
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.
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1450786
Thanx jjmartin,
I thought that was pretty clear, but guess not.
0
 

Author Comment

by:aaagarb
ID: 1450787
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.?

0
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 1450788
OK. Here is modification.

Private Sub Command1_Click()
      With Timer1
         .Interval = 5000
         .Enabled = True
      End With
      Dim ret As String
      ret = InputBox("I should disappear in five seconds.", MsgTitle, "default value")
End Sub

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:aaagarb
ID: 1450789
works fine..thanks for persevering.

0
 
LVL 4

Expert Comment

by:Chizl
ID: 1450790
I think he was looking for someone to catch the fish for him not learn how to catch the fish for himself.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1450791
Nooo, MsgTitle was on a wrong place. It confused me, also.
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1450792
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.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1450793
>really confused (RC)
OK. I can prove you everybody can be RC. See your e-mail box in a minute.
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1450794
Mathmatics is a wonderful thing..  :)
0
 
LVL 4

Expert Comment

by:Chizl
ID: 1450795
Now that I know who you are..  
0
 

Author Comment

by:aaagarb
ID: 1450796
Not the forum for "can you top this?" wars.
Thanks both for your time and comments.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now