1

I have a textbox on a userform that gets its value from a barcode scanner.
Unfortunately sometimes the cursor skips half way through the scan and only enters part of the name.
Is there a way to validate that the full scan has completed.

I can have a sheet in the background with a full list of all the codes so could validate against if this makes it easier?

Any help would be appreciated.

Thanks Al

0

1 Answer 1

2

You could try something like this:

Dim ScannedString As String
Scannedstring = Textbox1.Text

Dim StringFound as String

'Range of all Codes
Dim CodeRng as Range 'change this to whatever your list range is ofcourse
set CodeRng = ThisWorkbook.Sheets("Sheet1").Range("A1:A10") 

For each code in CodeRng
    If code = ScannedString Then
        StringFound = code
        Exit For
        'The scanned code is found in the list so nothing is wrong
    End If
Next code

If StringFound = "" Then
    MsgBox "The code you scanned does not exist on the list. Please Scan again."
End If
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.