QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 Return to Index  

My Entry

February 19 2011 at 6:04 PM
Anonymous  (Login AlGoreIthm)


Response to Challenge: too many IF - THENs


PRINT " Type any key a-z (A-Z) or 0-9"
PRINT " ESC to end"
PRINT

q$(1) = "12345qwertQWERT"
q$(2) = "67890yuiopYUIOP"
q$(3) = "ghjklbnmGHJKLBNM"
q$(4) = "asdfzxcvASDFZXCV"

WHILE K$ <> CHR$(27)

quadrant% = 0

K$ = INKEY$

FOR l% = 1 TO 4

quadrant% = quadrant% + l% * SGN(INSTR(q$(l%), K$))

NEXT

IF quadrant% <= 4 AND quadrant% >= 1 THEN PRINT "KEY " + K$ + " is in Quadrant" + STR$(quadrant%)


WEND

 
 Respond to this message   
Responses