0

Am using An inputbox in my form.

If i Press OK the code is fine. When i Press cancel the Program displayin an error. Wat should i Do ?

4
  • 3
    please explain with code Commented Oct 26, 2010 at 10:06
  • 2
    What you should do is refine your question and be alot more specific. Maybe you should even attached code examples of what you are trying to do. Commented Oct 26, 2010 at 10:06
  • This question is not answerable in this state. Please clarify it Commented Oct 26, 2010 at 10:17
  • 1
    @anishmarokey @Younes @samy I agree the question would be a whole lot better with some example code, but in fact InputBox is so simple that the question can be answered in its current state. Also, of course, the documentation explains the behaviour on pressing cancel - it's very simple. Commented Oct 26, 2010 at 15:05

3 Answers 3

3

You should look for an empty string

    Dim MyString As String

    MyString = InputBox("Please enter something", "Request Info", Nothing)
    If (MyString Is Nothing OrElse MyString = "") Then
        'User hit cancel
    Else
        'Read MyString
    End If
Sign up to request clarification or add additional context in comments.

Comments

1

Change the code that is after the InputBox to support empty strings. InputBox will return an empty string if you cancel so the reason for the error must be that your code expects the string to have a lenght > 0.

If you edit the question to show the code that calls InputBox as well as a few lines following that line, someone can probably point out the exact error.

Comments

1

See the documentation for a working sample:

Interaction.InputBox Method

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.