Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 1.00 KB | None | 0 0
  1. SUB ValidateOption (Choice$, Min, Max, Flag)
  2. REM This subroutine will ensure that the OPTION selcted was valid. IF it IS valid
  3. REM Flag = 0, IF NOT Flag = 1
  4. PRINT
  5. SELECT CASE VAL(Choice$) AND Min AND Max
  6.     CASE IS Max < INT(VAL(Choice$))
  7.         Flag = 1
  8.         PRINT "Sorry, but the value you have entered is far too big"
  9.         PRINT "Please choose again between"; Min; "and"; Max
  10.     CASE IS INT(VAL(Choice$)) < Min
  11.         Flag = 1
  12.         PRINT "Sorry, but the value you have entered is far too small"
  13.         PRINT "Please choose again between"; Min; "and"; Max
  14.     CASE IS LEN(Choice$) = 0
  15.         Flag = 1
  16.         PRINT "Sorry, but you have not entered a value"
  17.         PRINT "Please choose a number between"; Min; "and"; Max
  18.     CASE IS INT(VAL(Choice$)) > Min AND INT(VAL(Choice$)) < Max
  19.         Flag = 0
  20.     CASE IS ELSE
  21.         Flag = 1
  22.         PRINT "Sorry, but you are using inappropriate characters"
  23.         PRINT "Please choose a number between"; Min; "and"; Max
  24. END SELECT
  25. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement