QBasic Programming

On this page, you will find some small QBasic programs and functions that I have written. If you find something useful and want to incorporate it into your program, you have my permission to do so. Just copy and paste whatever you need. Everything here is freeware.

I learned QBasic programming language when I was 12 years old. Later I learned C, x86 assembly, Perl, and JavaScript. Programming is one of my hobbies. Most people don't program in QBasic anymore, and I rarely do as well. But this is still a nice language, and it's great for beginners.

My QBasic Programs

SOKOBAN.ZIP - I wrote this game for my brother for Christmas. Comes with 18 levels. You can play it in Windows XP in a DOS box, but for best experience you need to run it in native DOS mode. This is a maze game. The program allows you to play and advance to the next level, or you can create your own levels. The leves are saved in plain text files with SMZ file extension. MATH.BAS - I made this math practice program for my school when I was 15. It allows students to practice simple addition, subtraction, multiplication, and division. It records your name along with each calculation and each answer you gave and how long it took you to complete the level. It allows the teacher to look at the records of each student and sort the results.
VIEWFILE.BAS - This is a simple text file viewer with a scrollbar. In the title bar it shows you the file's name and size. In the status bar, it shows the the number of lines, current line, TAB size, and the date. Pressing F1 displays the keyboard shortcuts. UNWRAP.BAS - When you run this program, it creates a ZIP file. Inside this ZIP file, you will see a file called FILEWRAP.BAS. This program can convert any binary file into a plain text BASIC program. And when you run that program, it recreates the original file that was wrapped.
MENULIB.BAS - This isn't really a program. It's a library that contains functions to draw menus, windows, popup message boxes, and so forth. It also allows you to work with the mouse. QLIB.BAS - This is a function library that allows you to work with 8-byte unsigned integers in QBasic 1.1. These numbers are also called quad-words, and they can be up to 20 digits long! This program shows you how to work with such large numbers. As an added bonus, it has a function to solve the knapsack problem.

Math

EVAL.BAS - Solves a simple problem like 3-4*(2+9)

PI.BAS - Calculates the value of PI

PRIMES.BAS - finds primes and factors

RANDOM.BAS - prints random numbers in various ways

CCV.BAS - This program tests credit card numbers to see if they are valid.

Strings

STRINGS.BAS - This library contains a bunch of functions that help you work with strings and numbers: GETKEY(), MAX(), MIN(), CEIL(), CMPINT(), ADDINT$(), SUBINT$(), BIN2BIG$(), ROL$(), XCRYPT$(), SHRINK$(), EXPAND$(), BETWEEN$(), BEFORE$(), AFTER$(), STRREV$(), QUOTE$(), SUFFIX$(), PREFIX$(), STRRID$(), STRCOUNT(), REPLACE$(), RINSTR(), STRCMP(), SUBSTR$(), GETCHAR(), CENTER(), LHEX$(), TOHEX$(), TOBIN$(), FROMHEX(), HEX2BIN$(), STR2HEX$(), STR2BIN$(), SPLIT(), MERGE$(), SWAPWORD$(), COLLAPSE$(), REVERSE$(), WORDCOUNT(), SETWORD(), GETWORD$(), INLIST(), STRSHIFT$(), LONGTOBIN$(), LONG2HEX$(), WORD2HEX$(), BIN2HEX$(), HEX2STR$(), BIN2STR$(), CHARCOUNT$(), SHUFFLE$(), RANDOM$(), INSERT(), QSORT(), ADDSALT$(), SHORTEN$(), SCREENLOAD(), SCREENSAVE(), SCREENCOPY(), PRINTB(), CRC$(), QHEX$()

SORT.BAS - Sorts an array of strings using the bubble sort algorithm

REPLACE.BAS - Replaces part of a string

WORDS.BAS - This file contains functions to capitalize words: Convert to sentence case, title case, reverse case, random case. Capitalize every other letter. Capitalize the first letter only. Capitalize matched word only.

Graphics

LINEDEMO.BAS - a lines screen saver (graphics mode)

TXTSTARS.BAS - stars screen saver in text mode

CENTER - Prints text in the center

STAR.BAS - this program draws a star in 5 lines of code

SINWAVE.BAS - draws a sine wave (graphics mode)

COUNTRY.BAS - Menu program allows you to select your country from a list

HILIGHT.BAS - This program prints BASIC source code with syntax highlighting

Low-Level

MEMDUMP.BAS - view the contents of your memory

XCMOS.BAS - wipes the contents of CMOS memory

INTLIST.BAS - saves & displays interrupt vectors

ASM - Runs assembly routine (hex codes)

REBOOT.BAS - this program can reboot Windows and DOS

Misc

GWB2TXT.BAS - Converts old GW-BASIC binary BAS files to plain text

FILESIZE - Returns the correct size of large files

WINDOWS - Tests to see if Windows is running

DATE.BAS - displays the current date

VBSCRIPT.VBS - This VBScript program is written in QBASIC style

Basic Programming Links

  • QBasic News Forum
  • QB64 Forum
  • TekTips QBasic Forum
  • Pete's QBasic Site
  • The QBasic Forum
  • QBasic Cafe Forum
  • Basic/QBasic/GWBasic FB Forum
  • QBasic is Fun! FB Forum
  • QBasic Programmers FB Forum
  • QBasic/Python/JavaScript FB Forum
  • PureBasic Forum
  • FreeBasic Forum
  • PowerBasic Forum
  • VBForums
  • Convert EXE to BAS
  • Visual Basic 6.0 Programming
  • Visual Basic Directory
  • Visual Basic Programming Forum
  • XBasic Overview
  • XBasic Download
  • XBasic Discussion
  • Liberty Basic
  • Liberty Basic Community Forum
  • Source Code of GWBasic
  • PC-Basic Download
  • Last Update: July 25, 2023