Code archives/Algorithms/Allowed letters
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
How to allow only wanted letters to be entered. In past i did all this by long if sentence to allow only the valid letters in my games and stuff, but i found a neat technique instead of it. In this example only upper cased letters are allowed | |||||
Print "Waiting for correct letter to end..." AllowedLetters$ = "ABCDEFGHIJKLMNOPQRSTUVWXY" While Not Instr(AllowedLetters$, key$) key$ = Chr$(GetKey()) Wend End |
Comments
| ||
Modified program with Line2 below so it will run properly in console: Print "Waiting for correct letter to end..." key$="Z" AllowedLetters$ = "ABCDEFGHIJKLMNOPQRSTUVWXY" While Not Instr(AllowedLetters$, key$) key$ = Chr$(GetKey()) Wend End |
Code Archives Forum