+ Reply to Thread
Results 1 to 7 of 7

How to handle cancel when using the inputbox method

  1. #1
    Lawood
    Guest

    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. #2
    Rowan Drummond
    Guest

    Re: 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. #3
    RB Smissaert
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    RB Smissaert
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    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

  6. #6
    Rowan Drummond
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    >
    >> 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.

    >
    >


  7. #7
    Lawood
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1