Canceling an Input Box? 
Author Message
 Canceling an Input Box?

If the user clicks CANCEL, then the string returned by the InputBox function
will be blank, even if there are characters in the text box, and even if
those characters are the default value.

If the user clicks OK and there is nothing in the text box, it is exactly
the same as if they clicked CANCEL.

To make the CANCEL button work, test for the length of the string before you
try to do a CDate conversion.  Otherwise, if you try to execute the CDate
conversion on a null or empty string, you will get an Error 13 - Type
mismatch error.

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Quote:

>How can I allow a user to click CANCEL and exit this sub:



Sun, 06 Aug 2000 03:00:00 GMT  
 Canceling an Input Box?

Tony

Does anyone seriously use InputBox? Your answer highlights the basic
design flaw in it: that clicking OK with no text is indistinguishable
from clicking Cancel. This is illogical - the first case is a potential
error, the second a positive instruction to end the transaction.

It is much better to write a bespoke form.

Regards
{*filter*}

Quote:

>If the user clicks CANCEL, then the string returned by the InputBox
function
>will be blank, even if there are characters in the text box, and even
if
>those characters are the default value.

>If the user clicks OK and there is nothing in the text box, it is
exactly
>the same as if they clicked CANCEL.

>To make the CANCEL button work, test for the length of the string
before you
>try to do a CDate conversion.  Otherwise, if you try to execute the
CDate
>conversion on a null or empty string, you will get an Error 13 - Type
>mismatch error.

>--

>Tony Selke

>(please remove the _No-Junk-Mail_ prior to responding)

>/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


>>How can I allow a user to click CANCEL and exit this sub:



Mon, 07 Aug 2000 03:00:00 GMT  
 Canceling an Input Box?

Sorry, but I just have to ask.

What is a "bespoke" form?



Quote:
>Tony

>Does anyone seriously use InputBox? Your answer highlights the basic
>design flaw in it: that clicking OK with no text is indistinguishable
>from clicking Cancel. This is illogical - the first case is a potential
>error, the second a positive instruction to end the transaction.

>It is much better to write a bespoke form.

>Regards
>Dick

John McKee



Tue, 08 Aug 2000 03:00:00 GMT  
 Canceling an Input Box?

Heh.

I never said I *use* InputBoxes.  I just answered the question.  As for any
flaws, to be honest, they are no worse than anything you would have to do
yourself if you were to collect information from a pop-up window.  The
mistake I think people make is in thinking that it is a built in VB feature,
so it must meet all your needs.  That usually leads to poor debugging.
People who use an InputBox to get a number from the user and then blithly
use the Val of the response in their program are just begging for me to
enter something like "12L3" to see if it either crashes on a CLng-type
function, or proceeds with a value of 12 as a result of the hated Val
function.

When I do use an InputBox (which is, admittedly, a rare occurance) I do a
full check on the information I get back.  If it's a number I make sure that
it is numeric, within certain max and min bounds, and of the proper format
to be used before subjecting it to a conversion statement.

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Quote:

>Tony

>Does anyone seriously use InputBox?



Tue, 08 Aug 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. VB5: Canceling an input box...

2. VB5: Canceling an Input Box?

3. Capture cancel in input box?

4. Testing for Cancel in Input Box

5. Cancel Input Box

6. Cancel button on Input Box

7. Getting rid of the cancel button in input box

8. Input Box Cancel Command

9. Formatting date input in Input Box

10. Canceling input In Visual Basic

11. validating input - cancel LostFocus?

12. InputBox No input vs Cancel

 

 
Powered by phpBB® Forum Software