|
-
Feb 14th, 2000, 02:18 AM
#1
Thread Starter
Hyperactive Member
How can I detect if the Cancel button has been clicked on my inputbox.
I hate input boxes but there is a prerequisite on my course to use them! 
------------------
Matt G
Either [email protected]] or [email protected]
-
Feb 14th, 2000, 02:32 AM
#2
New Member
there might be a better way than this but if they hit cancel the inputbox function will return "" (nothing).
myStr = inputbox("enter name")
if ( myStr = "" ) then
' they hit cancel
end if
but that only works if it isn't allowable to actually leave the field blank.
-
Feb 14th, 2000, 04:17 PM
#3
Thread Starter
Hyperactive Member
That's how I initially did it. However I want to repeat the ionputbox if no reply is given ie FORCE the user to give an answer. I want to go down path x (repeat inputbox) if no answer is given and go down path y (clicked cancel - process accordingly) if cancel is clicked. :confused
My existing code is
Code:
Ask_User:
Ans=Inputbox("Answer is . . . ","Answer")
If len(Ans)=0 or Ans="" then
Goto Ask_User
End If
------------------
Matt G
Either [email protected]] or [email protected]
-
Feb 17th, 2000, 02:31 AM
#4
I think the best you can do is this, because as far as I know you can't distinguish between the click of the cancel button and a null response.
Code:
Dim Ans As String
Const DEFAULT = "Answer"
Do Until (Trim(Ans) > "") And Ans <> DEFAULT
Ans = InputBox("Answer is . . . ", "Please supply the Answer", DEFAULT)
If Ans = "" Then
MsgBox "You clicked Cancel or supplied a blank answer"
End If
Loop
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
[This message has been edited by MartinLiss (edited 02-17-2000).]
-
Feb 17th, 2000, 11:28 PM
#5
Hyperactive Member
MSDN states "If the user clicks Cancel, the returns a zero-length string ("").", so Marty's right. However, you could provide " " as default. If they hit Enter without making any changes, you would have " " returned instead of "" that Cancel returns. Another option would be to make your own inputbox from a small form.
Wade
-
Feb 18th, 2000, 12:37 PM
#6
Email me if you'd like a form that looks like an InputBox that will do what you want, or look for a recent post by Aaron Young for the code for a subclassed InputBox.
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
-
Feb 18th, 2000, 12:39 PM
#7
Email me if you'd like a form that looks like an InputBox that will do what you want, or look for a recent post by Aaron Young for the code for a subclassed InputBox.
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|