How to detect the input box is cancelled

  • Thread starter Thread starter Alan
  • Start date Start date
Hello, Alan:

InputBox returns 'Nothing' if the Cancel button is pressed:

dim a as string
a=inputbox("Write something or press Cancel")
if a is nothing then
msgbox("The user pressed Cancel.")
else
'Do something with a.
end if


Regards.


"Alan" <[email protected]> escribió en el mensaje | How do I know the use click the cancel button on the input box ?
|
|
 
So 'nothing' is keyword ?

Hello, Alan:

InputBox returns 'Nothing' if the Cancel button is pressed:

dim a as string
a=inputbox("Write something or press Cancel")
if a is nothing then
msgbox("The user pressed Cancel.")
else
'Do something with a.
end if
 
So 'nothing' is keyword ?

Yes, without the quotes.

Regards.
 
Alan said:
How do I know the use click the cancel button on the input box ?

An empty string is returned:

dim s as string
s = inputbox(...)
if s.length = "" then
'cancel pressed or no input
else
'
end if
 
* José Manuel Agüero said:
InputBox returns 'Nothing' if the Cancel button is pressed:

dim a as string
a=inputbox("Write something or press Cancel")
if a is nothing then
msgbox("The user pressed Cancel.")
else
'Do something with a.
end if

The documentation says that it returns "" if it's cancelled.
 
OK, I mistaked the function. InputBox returns "" if cancelled, but...
String.Length is an Integer, you should write:

If s="" Then

Or

If s.length=0 Then

Regards... and sorry for my mistake :(


"Armin Zingler" <[email protected]> escribió en el mensaje | > How do I know the use click the cancel button on the input box ?
|
| An empty string is returned:
|
| dim s as string
| s = inputbox(...)
| if s.length = "" then
| 'cancel pressed or no input
| else
| '
| end if
|
|
| --
| Armin
|
| http://www.plig.net/nnq/nquote.html
| http://www.netmeister.org/news/learn2quote.html
|
 
* José Manuel Agüero said:
OK, I mistaked the function. InputBox returns "" if cancelled, but...
String.Length is an Integer, you should write:

If s="" Then

Or

If s.length=0 Then
ACK.

Regards... and sorry for my mistake :(

No problem...

;-)
 
José Manuel Agüero said:
OK, I mistaked the function. InputBox returns "" if cancelled,
but... String.Length is an Integer, you should write:

If s="" Then

Or

If s.length=0 Then

Regards... and sorry for my mistake :(

And sorry for _my_ mistake. :-(( *argh* *gnrrrr*
 
Back
Top