To check keychangeof textbox  after a predifined time.

Posted on 2006-05-06
Medium Priority
Last Modified: 2010-05-01
  Quesion in one sentence - how to  restrict checking of  textbox keychange at  a given interval ?

 This is a basic appln and the user starts entering a value to a textbox.
 Is there a way in VB6 to see anything is keyed in for a predefined time (20sec).
  If nothing is keyed in ,then call a procedure.

 For eg.
##   The user starts entering 1234 and then waits for this predefined time(20sec).
        Then the procedure should be called passing the value 1234.
 ##  But if the user enters 1234 waits 10 sec and then keeps typing 5678
        Then 10 sec waiting should be ignored and  the procedure should be called with a value 12345678.

How to do this?
Question by:sgs1970

Expert Comment

ID: 16621380
Use a timer, and activate it using the keypress event for the textbox.  Just make sure you only activate it once.  Make a boolean or something and check it to see if you have activated the timer.
LVL 17

Accepted Solution

Cem Türk earned 375 total points
ID: 16621392
Dim idle As Integer

Private Sub Command1_Click()
MsgBox Text1
End Sub

Private Sub Form_Load()
idle = 0
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub

Private Sub Text1_Change()
idle = 0
If Len(Text1) = 8 Then
Call Command1_Click
ElseIf Text1 <> "" Then
Timer1.Enabled = True
Timer1.Enabled = False
End If
End Sub

Private Sub Timer1_Timer()
idle = idle + 1
Form1.Caption = idle & " seconds"
If idle = 20 Then
Call Command1_Click
idle = 0
Timer1.Enabled = False
End If
End Sub

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 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