Gambas/Subroutine

Subroutine in Gambas is a piece of code maintained as a block usable in many parts of your program. You need not write it twice. Routines can return a value depending on their return type. For instance we can return a String or Integer. Let's check the example below:

We declare return type of subroutine after AS written in close relation to the name of subroutine as we can see in examples above. There are some built in subroutines connected with events of windowed program. Such a type is Form_Open() fired when form opened. Special name for subroutines used in classes based on the object oriented principle is methods. To say it simple: Subroutine is reusable part of code. Another example in our code might be: