bshaen Posted April 4, 2005 Posted April 4, 2005 msg = inputbox("string") if user press cancel, the program will end, but i dont know how to declare it so that vb able to recognite it?? i am appreciated if u guys can help me, thank Quote
CanOz Posted April 4, 2005 Posted April 4, 2005 Hi bshaen Odd, that should not happen. Which Event are your calling the InputBox from? If you could post up the whole code for the Event it would help. Quote
Leaders snarfblam Posted April 4, 2005 Leaders Posted April 4, 2005 Are you trying to make the program end when the user clicks cancel? Or is it happening and you dont know why? Quote [sIGPIC]e[/sIGPIC]
bshaen Posted April 5, 2005 Author Posted April 5, 2005 Are you trying to make the program end when the user clicks cancel? Or is it happening and you dont know why? yeah, if the user click cancel button, its will terminate whole program, and if user jabe yet type any string in the input textbox, it's will promt it again. Quote
CanOz Posted April 5, 2005 Posted April 5, 2005 yeah' date=' if the user click cancel button, its will terminate whole program, and if user jabe yet type any string in the input textbox, it's will promt it again.[/quote']If the Cancel button on the InputBox is clicked it returns a Null String. You could check and see if your variable msg (from your first post) is Null or not and code accordingly If msg = "" then Application.Exti ElseIf msg <> "" Then Do While msg <> "string" msg = InputBox("Try again", "Try again", "Enter something") Loop ' code to do here if the correct word is entered. End If With this example, I am not sure if you are trying to get the user to enter some specific Text into the InputBox or not, it would look and see if the returned string was Null (or zero length) and Exit the Application. Otherwise it would check and see if the user enters the right word (string) it will do whatever. I assume that you want it to accept the user input at some point in time or you would end up with a never ending Loop. Hope this helps. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.