Thread: vbCancel
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default vbCancel

But he was making his comparison to vbCancel which is a two and is usable
with a msgbox, not an input box.

? vbCancel
2


You said hitting cancel in an inputbox returns zero - it doesn't

"When I hit Cancel (or X) on an InputBox, I get the returned value of 0

(Zero)."

Tested in the immediate window (cancel was selected)

? inputbox("abc")

------ it returned a null string

? typename(inputbox("abc"))
String

A vba inputbox always returns a string.

An empty string is coerced to zero in most cases if you force it to be used
as a number, but not always. For instance

? inputbox("abc") = 0
raises a type mismatch error when I hit cancel.

I just provided information on what an inputbox actually returns.


--
Regards,
Tom Ogilvy




wrote in message
...
Maybe, I'm missing something. I thought that he was trying to return a
number between 1 and 5.

Paul

--------------------------------------------------------------------------

----------------------------

According to help:

If the user clicks OK or presses ENTER , the InputBox function returns
whatever is in the text box. If the user clicks Cancel, the function

returns
a zero-length string ("").

you must have Ans dim'd as a number.