Programming Reference: Useful QBASIC Commands

By Z. Perry, published Sep 13, 2007
Published Content: 360  Total Views: 451,305  Favorited By: 6 CPs
Rating: 3.0 of 5
QBASIC is a programming language which is useful for creating many types of programs to run in Windows and DOS. It features a massive number of commands, some of which produce effects which can be achieved using other QBASIC commands in different ways. Even advanced programmers usually don't know all of them, as some are only necessary in specific types of programs. Read on to learn about some of the most frequently useful commands; simply type them in the QBASIC programming interface and press F1 if you need more details on their syntax and parameters...

CLS: Clears the screen of all text and graphics. No parameters are needed.

COLOR: Specifies the color scheme to be used; it is followed by two color numbers (COLOR ,) separated by a comma. For example, "COLOR 7,1" changes the color to white over blue.

END: With no parameters, this QBASIC command simply ends the program; it is not necessary to use END on a program's last line, in which it automatically ends, but can be useful for allowing users to exit the program.

FOR/NEXT: The FOR and NEXT commands require a set of program lines to be repeated a specific number of times. The FOR command starts the loop, while NEXT sends the program back to the command following FOR.

GOTO: Used to change to a different position in the QBASIC program code, usually identified by a line number. For example, "GOTO 75".

IF/THEN: The IF and THEN commands activate a particular function or change to a different line number if a particular statement is true, such as: IF DATE$="12-25-2007" THEN PRINT "Merry Christmas!"

INPUT: This useful programming command lets the user enter data which is to be stored in a variable, and may include a prompt. It can also be utilized to read data from an open file.

LOCATE: Moves the cursor to a specified row and column on the screen.

PRINT: This QBASIC programming command, unlike its name suggests, displays text or variable data on the screen. The text should follow it in quotation marks. It can also save data to open files.

Programming Reference: Useful QBASIC Commands

Simple program using each of these commands

Credit: Z. Perry

Copyright: Z. Perry

Comments
Type in Your Comments Below - (1000 characters left)
Your name:

Submit your own content on this or any topic. Get started »
Most Commented On