Input box problem

How can i know if a user answer an Inputbox with the "CANCEL" button or with the "OK" button but with a "" string?
fcpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
You create a form and make it look just like the standard inputbox, and use that form.. this is probably the easiest way of doing it.
0
cable4096Commented:
Try this:

Dim s_text As String

s_text = "" & InputBox("Enter your response", "Data Entry", "")

If s_text = "" Then
    MsgBox "Invalid Entry"
End If

The third parameter on the Inputbox is the default value. If the user cancels the Inputbox, it will be set to "", if they just press OK with nothing in the Inputbox, it will be set to "". If they type in a space or at least one character, it will not display the error in my code.

The first parameter in an input box is the prompt on the Inputbox, the second is the title on the Inputbox.

Does this help?
0
jgvCommented:
You can set the default for the inputbox (third parameter) to a space.

Dim x
x = InputBox("input something", , " ")

If 'ok' is selected then " " is returned. If 'cancel' is selected then "" is returned. You can distinguish the button that was pressed this way. However, I think VBmaster's solution is the better way to go. I rarely use the inputbox to retrieve user input. More professional and versatile to create your own.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

fcpAuthor Commented:
For Cable:
Sorry, but your code is not the solution: if the user click "CANCEL" or
"OK" with a empty string, it make the same thing.

For VBMaster and JGV:
I also like create forms to get user-input data, but for some strange "BOSS" reasons -and the boss is NOT a programmer :( - i prefere to use the inputbox. Maybe there is no answer for my question, i dont know...
0
mcriderCommented:
This is a direct quote from the InputBox Help Page:

"If the user clicks OK or presses ENTER, the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string ("")."

The only thing you can do is check to see if the returned string is "" or Len(string)=0

This is a limitation of using the InputBox... Therefore, if an InputBox has an initial value, and the user deletes all of the characters out of the InputBox and presses "OK" this is the same as pressing the "Cancel" button and your program should treat it this way.

If you don't want to work with this limitation, you must build your own form.


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fcpAuthor Commented:
As what i suspect, no way...
....maybe Subclassing? (yes, is more simple a custom form, is only for knowledge...)
0
fcpAuthor Commented:
Oh, i close question without care: vbmaster is the first that says "no way". How i can remedy my fault?
0
VbmasterCommented:
Maybe you can post a question asking if they can do that at the customer service section..

http://www.experts-exchange.com/Customer_Service/Experts_Exchange/

I think they will be happy to help you out, at least I heard people getting really fast reponse from them.
0
fcpAuthor Commented:
mmm... better i pose a "Fake" question for you, vbmaster.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.