QBasic Tutorial 36 - Making a Sub in QB64



As programs become more advanced, placing all the code in the main program can make the program more difficult to program, maintain, and understand. Slicing the program into sections can help. These sections are called by many names. The names include: subs, sub-modules, sub-procedures, procedures and sub-programs.

The way that the subs work is that the main program, another sub or function will call the sub. Once the sub is called, it will run. When the sub is done running the main program main program, another sub or function will continue with its code.

Before we can start programming with subs we have to know how to create the subs.
Subs can be created in QB64 by going to Edit --> New Sub and typing the name of your new sub in the box. Subs, can also be created by manually typing the sub’s code.

Code Download 
QBT36_1.BAS
QBT36_2.BAS
QBT36_3.BAS




QBasic / QB64 Links



QB64 is a free download at www.qb64.org

QB64 Wiki & Manual is found at www.qb64.org/wiki/Main_Page

QBasic 1.1 is found within OldDOS.exe.
OldDos is a free download at download.microsoft.com/download/win95upg/tool_s/1.0/W95/EN-US/olddos.exe

On some web browsers, the Microsoft link does not work, because the download comes as an exe file. A zip file of OldDOS can be found at www.pcxt-micro.com/download.html

QBasic 1.1 needs DOSBox to run on Windows Vista and greater, Mac, and Linux.
DosBox is a free download at www.dosbox.com

Free QB64/QBasic Code 

QBasic.Net - www.qbasic.net

Pete's QBasic Site - www.petesqbsite.com/index.php

QB45 - qb45.org

Phatcode - games.phatcode.net