Results 1 to 3 of 3

Thread: How to activate a cancel btn in a Input box

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    I am using a input box to ask quantity and saving it for a calculation. But i need to know how, what if the user clicks on cancel, how do I make the program end instead of giving an error message.

    temp = msgbox("blah", vbYesNo, "blah2")
    if temp = vbYes then
    end
    end if

    this works with msgboxes but not with inputboxes, is there a solution????

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Code:
    Dim TheInput As String
    
    TheInput = Inputbox("Please enter something")
    
    If TheInput = "" Then
        Msgbox "You Clicked Cancel."
    Else
        Msgbox "Thanks for entering something!"
    End If
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176
    The only problem with that is the user could just click ok without entering a value executing the "Cancel" code.

    If you want a more reliable way then download my Dialog Extensions DLL, set a reference to it then use the InputBoxEx() function, i.e.
    Code:
    Private Sub Command1_Click()
        On Error GoTo Canceled
        Caption = InputBoxEx("Enter Something", CancelError:=True)
        Exit Sub
    Canceled:
        Caption = "Canceled"
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width