How to Program a Slot Machine in QBasic

Written by darrin koltow
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Program a Slot Machine in QBasic
QBasic slot machine simulators typically have little source code. (money image by yannik LABBE from

The programs you can make with the beginner's development language QBasic include games. Slot machine simulators fall into this category. Making such a game involves several steps. One of those steps, for some approaches to coding this type of game, includes designing the interface that mimics the facade of a slot machine. Another step is calling on QBasic's statements for producing random numbers, RANDOMIZE and RND. One advantage of making a QBasic slot machine game is the ability to display custom, hand-drawn graphics in the slot windows.

Skill level:

Things you need

  • QBasic

Show MoreHide


  1. 1

    Open, in a word processor, the source files of an open source program that simulates a slot machine. Sample slot machine programs include Casino Sim and Tuty Fruty Slot. These are not QBasic programs, but you'll convert them to QBasic.

  2. 2

    Print the source files and make a new set of blank source files with the same names as the originals.

  3. 3

    Type into each new source file the statements from the corresponding non-blank file. This task requires you to read closely the original slot machine's source code. This close reading provides insight into how the game works.

  4. 4

    Write comments, as you're typing each statement, that describe the statement's purpose. For example, for the statement "if (slot1==slot2==slot3) blnJackPot = true;" you may write "This statement is comparing the values of each slot with the other slots. If all slots have the same value, a jackpot is flagged."

    Write these comments using the characters that delimit comments, as defined by the slot machine's programming language. Many programming languages use the characters "/ and /" to bracket comments. If you don't know or aren't sure of a statement's purpose, put a question mark in the comment's brackets.

  5. 5

    Retype the program's source files again but do so from memory this time. You'll need to refer to the printouts at first but after a few typing sessions you'll be able to recite the program from memory. According to Texas A&M neuroscience professor Bill Klemm, since memorisation builds understanding, finishing this task successfully will complete your understanding of the program. You can then translate it to QBasic.

  6. 6

    Write a translation of each statement from the original slot machine game in your QBasic programming editor. Read a description of QBasic's syntax in your editor's help file if don't know how to translate a particular statement.

  7. 7

    Run the program after translating all statements in the original slot machine program to play the QBasic slot machine. If the program doesn't work, use your editor's code-stepping tools to find and fix all errors. (Code-stepping is executing a program one statement at a time.)

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.