Microsoft KB Archive/47754

= Can't Trap &quot;String Input When a Numeric Value Is Expected&quot; =

Article ID: 47754

Article Last Modified on 11/21/2006



This article was previously published under Q47754



SUMMARY
The documentation incorrectly states that you can &quot;...safeguard your program from user errors such as string input when a numeric value is expected...&quot; in the following manuals:


 * 1) &quot;Microsoft QuickBasic 4.0: Programming in Basic: Selected Topics&quot; manual for Versions 4.00 and 4.00b, Page 279
 * 2) &quot;Microsoft QuickBasic 4.5: Programming in Basic&quot; manual for Version 4.50, Page 225
 * 3) &quot;Microsoft Basic Compiler 6.0: Programming in Basic: Selected Topics&quot; for Microsoft Basic Compiler Versions 6.00 and 6.00b, Page 279

This documentation error is not present in Microsoft Basic PDS Version 7.00.

It is not possible to use the ON ERROR GOTO statement to trap the &quot;Redo from Start&quot; error that occurs for the INPUT statement when a string is entered and a numeric value is required. To avoid the &quot;Redo from Start&quot; error message, you must use a different form of input, such as the LINE INPUT statement or the INKEY$ function.

Because LINE INPUT accepts all characters until it encounters a carriage return, you must parse the input string yourself using string manipulation (e.g. MID$, INSTR) and type conversion (e.g. VAL).

For a code example of a line-input routine using the INKEY$ statement, query on the following words: INKEY$ and CTRL+BREAK and DEBUG and GOSUB

Additional query words: QuickBas BasicCom

Keywords: KB47754

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.