Happy_dancer
New Member
- Joined
- Aug 30, 2023
- Messages
- 3
- Office Version
- 365
- 2010
- Platform
- Windows
Hi Everyone (first time poster, multiple time forum user),
I have part of a macro that is asking a user for a value and storing this as a String limited to 9 characters (a few reasons why this needs to be limited to 9).
However, if the user selects cancel, [X], or leaves blank the IF conditions to display "You pressed cancel or[X]" and "You did not enter anything" are not being displayed.
This code works if the string is not set to a character limit - anyone know why limiting the string characters is affecting this code and how to get around the issue?
Appreciate the help!
I have part of a macro that is asking a user for a value and storing this as a String limited to 9 characters (a few reasons why this needs to be limited to 9).
However, if the user selects cancel, [X], or leaves blank the IF conditions to display "You pressed cancel or[X]" and "You did not enter anything" are not being displayed.
This code works if the string is not set to a character limit - anyone know why limiting the string characters is affecting this code and how to get around the issue?
VBA Code:
Dim StrInput1 As String * 9
StrInput1 = InputBox("Please Scan or Type BARCODE below", "Barcode Checker")
If (StrPtr(StrInput1) = 0) Then
MsgBox "You pressed cancel or[X]"
Exit Sub
ElseIf (StrInput1 = "") Then
MsgBox "You did not enter anything"
Exit Sub
End If
Appreciate the help!