User defined functions are listed as separate windows within QBASIC. Select View to switch between various functions.
Each user=defined function starts with BEGIN FUNCTION FunctName (x, y,z) and ends with END FUNCTION. The code between these two lines is executed whenever the function is envoked from main program, from another function, or SUB, or from itself. FunctName is a name for your function (choose a descriptive one). Arguments (x,y,z) are the variables passed to the function.
There are just a couple things to remember when making functions:
Once a function is created, you can use it from within a program in the same way as the build in functions. The name of the function carries its value, eg x=FunctName(23)+FunctName(24). Notice that the function can also change values of the variables in its arguments, and perform any other tasks - this behavior is like that of any program.
SUBs act like functions, except that the name doesn't carry ``value" and the only change (if any) is to the variables passed. To invoke SUB from the program, use CALL SubName(Parameters). This method is recommended as it is more resistant to typographical errors.
You can pass a whole array as an argument of a function. The arrays are recognized by the parentheses: FuncName(A()) is a function of array A().