View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff[_8_] Harald Staff[_8_] is offline
external usenet poster
 
Posts: 28
Default Cancel Input Box error

"GS" skrev i melding ...
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.


Harald,
Thanks for sharing an 'old trick'; these are always welcome!

Unfortunately, it doesn't work when users "enter nothing" because doing so
(leave empty, hit Enter key) returns an empty string (or vbNullString) and
so StrPtr is not zero...


I must have explained myself poorly. This is the whole point, separating
cancelling from entering nothing. Entering nothing is a valid input in many
operations.This works.

Best wishes Harald