ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to handle cancel when using the inputbox method (https://www.excelbanter.com/excel-programming/348047-how-handle-cancel-when-using-inputbox-method.html)

Lawood

How to handle cancel when using the inputbox method
 
How can I handle the return from a CANCEL button that is clicked on when the
inputbox method is present. As far as I can tell there is nothing available
to test on. The Inputbox Function is not an option. Thanks in advance.

Rowan Drummond[_3_]

How to handle cancel when using the inputbox method
 
Is this what you want?

Dim rslt As Variant
rslt = Application.InputBox("Enter Stuff")
If rslt = False Then
MsgBox "Cancelled"
Else
MsgBox rslt
End If


Hope this helps
Rowan

Lawood wrote:
How can I handle the return from a CANCEL button that is clicked on when the
inputbox method is present. As far as I can tell there is nothing available
to test on. The Inputbox Function is not an option. Thanks in advance.


RB Smissaert

How to handle cancel when using the inputbox method
 
Try this:

Sub test()

Dim strTemp As String

strTemp = InputBox("testing the Cancel button")

If StrPtr(strTemp) = 0 Then
MsgBox "Cancel was pressed"
Else
MsgBox "OK was pressed"
End If

End Sub


RBS

"Lawood" wrote in message
...
How can I handle the return from a CANCEL button that is clicked on when
the
inputbox method is present. As far as I can tell there is nothing
available
to test on. The Inputbox Function is not an option. Thanks in advance.



RB Smissaert

How to handle cancel when using the inputbox method
 
If you enter a zero and do OK it will be a Cancel.
I think using StrPtr is the only way.

RBS

"Rowan Drummond" wrote in message
...
Is this what you want?

Dim rslt As Variant
rslt = Application.InputBox("Enter Stuff")
If rslt = False Then
MsgBox "Cancelled"
Else
MsgBox rslt
End If


Hope this helps
Rowan

Lawood wrote:
How can I handle the return from a CANCEL button that is clicked on when
the inputbox method is present. As far as I can tell there is nothing
available to test on. The Inputbox Function is not an option. Thanks in
advance.



Rowan Drummond[_3_]

How to handle cancel when using the inputbox method
 
I have just been reading up on StrPtr following your post - it's a new
one for me. Thanks.

Regards
Rowan

RB Smissaert wrote:
If you enter a zero and do OK it will be a Cancel.
I think using StrPtr is the only way.

RBS

"Rowan Drummond" wrote in message
...

Is this what you want?

Dim rslt As Variant
rslt = Application.InputBox("Enter Stuff")
If rslt = False Then
MsgBox "Cancelled"
Else
MsgBox rslt
End If


Hope this helps
Rowan

Lawood wrote:

How can I handle the return from a CANCEL button that is clicked on
when the inputbox method is present. As far as I can tell there is
nothing available to test on. The Inputbox Function is not an option.
Thanks in advance.




Leith Ross[_378_]

How to handle cancel when using the inputbox method
 

Hello Lawood,

Just for reference, the InputBox method returns a boolean False when
Cancel is pressed and the InputBox function returns an empty string.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=493240


Lawood

How to handle cancel when using the inputbox method
 
That did the trick. Thanks to everyone for their help.

"Lawood" wrote:

How can I handle the return from a CANCEL button that is clicked on when the
inputbox method is present. As far as I can tell there is nothing available
to test on. The Inputbox Function is not an option. Thanks in advance.



All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com