November 28, 2020, 01:22:14 AM

Author Topic: [bb] Allowed letters by Andres [ 1+ years ago ]  (Read 423 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Allowed letters by Andres [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Allowed letters
Author : Andres
Posted : 1+ years ago

Description : 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


Code :
Code: BlitzBasic
  1. Print "Waiting for correct letter to end..."
  2.  
  3. AllowedLetters$ = "ABCDEFGHIJKLMNOPQRSTUVWXY"
  4.  
  5. While Not Instr(AllowedLetters$, key$)
  6.     key$ = Chr$(GetKey())
  7. Wend
  8. End


Comments :


rolow(Posted 1+ years ago)

 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())WendEnd


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal