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

My go at it

March 9 2011 at 6:32 PM
  (Login rpgfan3233)


Response to Challenge: too many IF - THENs

quads$ = "12345EQRTW06789IOPUYBBBGHJKLMNAAACDFSVXZ"

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

WHILE k$ <> CHR$(27)

k$ = INKEY$

quadrant$ = MID$(STR$(9 + INSTR(quads$, UCASE$(k$))), 2, 1)

IF quadrant$ <= "4" AND LEN(k$) THEN
PRINT "Key "; k$; " is in quadrant "; quadrant$
END IF
WEND

I could have just divided by 10 the sum of the result of INSTR(...) and 9, but what fun would that be? :P

 
 Respond to this message