Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
ON UEVENT, UEVENT Statements and SetUEvent Routine Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example uses the UEVENT and ON UEVENT statements to enable user-
' defined event trapping. The SetUEvent routine signals a user-defined event
' and passes control to an event-handling routine. This example is a limited
' illustration of UEVENT statements, which are best suited for interfacing
' hardware to a computer.
' Note: To use this program or any user-defined event trapping, you must load
' the Quick library VBDOS.QLB with the /L option when you start Visual Basic.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
CLS ' Clear the screen
PRINT "This program asks for 10 numbers between 0 and 9, inclusive."
PRINT "As each number is input, it is evaluated to determine whether"
PRINT "it is odd or even. Odd numbers cause a user-defined event"
PRINT "to occur. Even numbers do not.": PRINT
ON UEVENT GOSUB Event1
UEVENT ON
DO
PRINT "Enter a number --> ";
N = VAL(INPUT$(1)): PRINT N: PRINT
SELECT CASE N
CASE 1, 3, 5, 7, 9
PRINT "An odd number was input causing a user-defined event.";
CALL SetUEvent
CASE ELSE
PRINT "No user-defined event occurred.": PRINT
END SELECT
LoopCount = LoopCount + 1
LOOP UNTIL LoopCount = 10
END
Event1:
PRINT "Now processing the UEVENT. The odd number was"; N
PRINT
RETURN