Microsoft KB Archive/32164

= Basic Example of CALL SetUEvent, ON UEVENT GOSUB Trapping =

Article ID: 32164

Article Last Modified on 11/21/2006

-

APPLIES TO


 * 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 Q32164



SUMMARY
The following products support user-defined event trapping with the statements ON UEVENT GOSUB, UEVENT ON, and SetUEvent:


 * 1) QuickBasic Compiler Versions 4.00b and 4.50
 * 2) Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2
 * 3) Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2

Microsoft QuickBasic Versions 4.00 and earlier do not support user-defined events.

Below is a short example of how to trap a user-defined event.



MORE INFORMATION
You can cause a user-defined event in a program by executing the CALL SetUEvent statement whenever a desired condition occurs. To CALL the SetUEvent routine in the QuickBasic environment, you must invoke QB.EXE with the /L switch to load QB.QLB. For Basic PDS 7.00 you must start QBX with /L to load QBX.QLB. An .EXE program that CALLs SetUEvent must be linked to QB.LIB because the SetUEvent routine is located in the QB.LIB library provided on the product disk. For Basic PDS 7.00 you must link with QBX.LIB.

The UEVENT ON statement turns on trapping of user-defined events. The < ON UEVENT GOSUB label > statement instructs a program where to go when a user-defined event occurs.

The following example invokes the event handler if the value 5 is accepted from the keyboard: ON UEVENT GOSUB event1 UEVENT ON INPUT &quot;enter a number&quot;; a IF a = 5 THEN CALL setuevent END event1: PRINT &quot;invoked event handler with value&quot;; a  RETURN

Additional query words: QuickBas BasicCom

Keywords: KB32164

-

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

© Microsoft Corporation. All rights reserved.