Microsoft KB Archive/58213

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 14:14, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Article ID: 58213

Article Last Modified on 11/21/2006


  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0

This article was previously published under Q58213


The two programs below show two different methods of emptying the keyboard input buffer. The first program uses a DOS interrupt to clear the buffer, while the second program uses the INKEY$ function.

This information applies to Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50 for MS-DOS; to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS; and to Microsoft Basic Professional Development System (PDS) Version 7.00 for MS-DOS.


Code Example 1

The following program uses DOS interrupt 21 hex (33 decimal) with function 0C hex (12 decimal), which flushes the input (type-ahead) keyboard buffer. To run this program inside the QuickBasic (QB.EXE) environment, you must load the Quick library QB.QLB with the /L option. To run this program inside the QuickBasic Extended (QBX.EXE) environment supplied with Microsoft Basic PDS Version 7.00, load the Quick library QBX.QLB with the /L option.

   'For Basic PDS Version 7.00 you must instead use $INCLUDE: 'QBX.BI'
   DIM inregs AS regtype
   DIM outregs AS regtype = &HC00   ' 0C hex goes in AH, high byte of AX register
                       ' 00 goes in AL, the low byte of AX register
   CALL INTERRUPT(&H21, inregs, outregs)

Code Example 2

The following program uses the INKEY$ function to read characters from the keyboard buffer until no more are available. This program can also be used under MS OS/2 protected mode when compiled with Microsoft Basic Compiler Versions 6.00 and 6.00b and Microsoft Basic PDS Version 7.00.

   WHILE INKEY$ <> ""

Additional query words: QuickBas BasicCom

Keywords: KB58213