Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting Cancel in an InputBox Method Connie Excel Discussion (Misc queries) 2 October 19th 06 01:32 PM
Cancel button in Inputbox method MiRa Excel Programming 2 November 14th 03 01:04 PM
Inputbox method using type:=8 - How to Cancel? Joe 90 Excel Programming 0 July 10th 03 12:24 AM
Inputbox method using type:=8 - How to Cancel? Harlan Grove[_5_] Excel Programming 1 July 9th 03 12:06 AM
Inputbox method using type:=8 - How to Cancel? Jim Cone Excel Programming 0 July 8th 03 06:15 PM


All times are GMT +1. The time now is 11:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"