inputbox

bshaen

Newcomer
Joined
Mar 10, 2005
Messages
19
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
 
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.
 
Are you trying to make the program end when the user clicks cancel? Or is it happening and you dont know why?
 
marble_eater said:
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.
 
bshaen said:
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.
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.
 
Back
Top