Cancel Input Box error
Hi friends
You have solved this, let me just share an old trick:
Sub test()
Dim S As String
S = InputBox("Enter anything or nothing:")
If StrPtr(S) = 0 Then
MsgBox "You cancelled"
Else
MsgBox "You entered:" & S
End If
End Sub
Opposed to other variables, VBA will not know how much memory a String will
need. So what it does when a string is used is to save it
"somewhere/anywhere available" and put a pointer, the address to the text, i
variable S. When you cancel, the string is not used and the stringpointer,
StrPtr, remains zero.
Beste wishes Harald
"L. Howard" skrev i melding
...
With the OK and CANCEL options, I tried all the commented out exit codes for
the Input Box and all produce an error on this line:
sNum = InputBox("Stock Number Required.", "Quantidade Retirada")
Otherwise the box and code work okay.
Howard
|