Search code examples
vbatriggerstextboxuserform

How to delay Userform TextBox1_Change() triggering until entering multiple characters singly is complete?


I have a macro which uses entered value from TextBox1. If a value is given to TextBox1 as a whole, the code runs fine. If a value is entered character by character (scanned with a handheld barcode scanner) the code: TextBox1_Change() triggers on every character.

How do I make the macro start only when the whole value is entered (the length of the value may differ)? Maybe there is a way to catch the barcode scanners ENTER?

Extra buttons to manually trigger the code are not an option.

Also asked here


Solution

  • Solved with this:

    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyReturn Then
    End If
    End Sub