Advertisement
Prithak

GUI Calculator [QBASIC]

May 26th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 3.40 KB | None | 0 0
  1. _FULLSCREEN
  2. DIM x AS INTEGER
  3. DIM y AS INTEGER
  4. DIM keypress AS STRING
  5. CONST size = 4
  6. x = 159
  7. y = 99
  8. main:
  9. SCREEN 13
  10. CLS
  11.  
  12. DO
  13.     COLOR , 7
  14.     'Making the cursor move
  15.     keypress = UCASE$(INKEY$)
  16.  
  17.     IF keypress = "W" THEN
  18.         CLS
  19.         y = y - 5
  20.     ELSEIF keypress = "S" THEN
  21.         CLS
  22.         y = y + 5
  23.     ELSEIF keypress = "A" THEN
  24.         CLS
  25.         x = x - 5
  26.     ELSEIF keypress = "D" THEN
  27.         CLS
  28.         x = x + 5
  29.     ELSEIF keypress = "E" THEN
  30.         CLS
  31.         GOTO calculator
  32.     END IF
  33.     CIRCLE (x, y), size, 3
  34.     LINE (74, 44)-(204, 69), 1, B
  35.     LOCATE 8, 12
  36.     PRINT "GUI Calculator"
  37.     LOCATE 15, 2
  38.     PRINT "Press E to Go"
  39. LOOP UNTIL keypress = "Q"
  40.  
  41. calculator:
  42. CLS
  43. LOCATE 1, 1
  44. PRINT "GUI CALCULATOR"
  45. DO
  46.     sizee = 4
  47.     keypress$ = UCASE$(INKEY$)
  48.  
  49.     IF keypress$ = "W" THEN
  50.         CLS
  51.         y = y - 5
  52.     ELSEIF keypress$ = "S" THEN
  53.         CLS
  54.         y = y + 5
  55.     ELSEIF keypress$ = "A" THEN
  56.         CLS
  57.         x = x - 5
  58.     ELSEIF keypress$ = "D" THEN
  59.         CLS
  60.         x = x + 5
  61.     ELSEIF keypress$ = "H" THEN
  62.         CLS
  63.         GOTO help
  64.     END IF
  65.     CIRCLE (x, y), sizee, 3
  66.     LINE (194, -1)-(194, 199), 1, BF
  67.     LOCATE 3, 28
  68.     PRINT "Number 1"
  69.     LOCATE 12, 28
  70.     PRINT "Number 2"
  71.     LOCATE 19, 28
  72.     PRINT "What to do?"
  73.     LOCATE 7, 1
  74.     PRINT "Press H for help"
  75.     LINE (214, 109)-(289, 129), 3, B
  76.     LINE (214, 39)-(284, 59), 2, B
  77.     LINE (214, 164)-(289, 184), 4, B
  78.     LINE (4, 24)-(59, 40), 5, B
  79.     FOR xs% = 209 TO 274
  80.         FOR ys% = 49 TO 59
  81.             IF x = xs% AND y = ys% AND keypress$ = "E" THEN
  82.                 LOCATE 7, 28
  83.                 INPUT a
  84.             END IF
  85.         NEXT
  86.     NEXT
  87.     FOR xs1% = 224 TO 279
  88.         FOR ys1% = 114 TO 124
  89.             IF x = xs1% AND y = ys1% AND keypress$ = "E" THEN
  90.                 LOCATE 16, 28
  91.                 INPUT b
  92.             END IF
  93.         NEXT
  94.     NEXT
  95.     FOR xs2% = 219 TO 279
  96.         FOR ys2% = 169 TO 179
  97.             IF x = xs2% AND y = ys2% AND keypress$ = "E" THEN
  98.                 LOCATE 22, 28
  99.                 INPUT operator$
  100.             END IF
  101.         NEXT
  102.     NEXT
  103.  
  104.     LOCATE 7, 28
  105.     PRINT a
  106.     LOCATE 16, 28
  107.     PRINT b
  108.     LOCATE 2, 1
  109.     PRINT "Result"
  110.     LOCATE 22, 28
  111.     PRINT operator$
  112.     LOCATE 23, 1
  113.     PRINT "Press Q to quit"
  114.     SELECT CASE operator$
  115.         CASE "+"
  116.             result = a + b
  117.             LOCATE 5, 2
  118.             PRINT result
  119.         CASE "-"
  120.             result = a - b
  121.             LOCATE 5, 2
  122.             PRINT result
  123.         CASE "*"
  124.             result = a * b
  125.             LOCATE 5, 2
  126.             PRINT result
  127.         CASE "/"
  128.             result = a / b
  129.             LOCATE 5, 2
  130.             PRINT result
  131.         CASE "MOD"
  132.             result = a MOD b
  133.             LOCATE 5, 2
  134.             PRINT result
  135.         CASE "^"
  136.             result = a ^ b
  137.             LOCATE 5, 2
  138.             PRINT result
  139.     END SELECT
  140. LOOP UNTIL keypress = "Q"
  141. END
  142. help:
  143. CLS
  144. PRINT "On the section ''What to do'' enter +,-,*,/,MOD and ^"
  145. PRINT
  146. PRINT "How do I even use this?"
  147. PRINT "The small circle is your cursor. The rectangles are the fields to enter a value or see the result! Move your cursor with W,A,S and D then take it to the middle of Number 1 field, and press E you will see what happens"
  148. PRINT
  149. PRINT "Thank you"
  150. PRINT "Press any key to continue"
  151. SLEEP
  152. GOTO main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement