Basic4ppc projects are made of one main file, with the extension "sbp" and any number
of modules files, with the extension "bas".
The main file holds the main module.
A module can include code, forms and controls and objects.
It is a good practice to separate large projects into several modules in order to make the
development process easier and simpler.
Modules can also be reused in several projects.
Creating a new module is done by choosing Modules - Add New Empty Module
(desktop) or Tools - Add New Empty Module (device).
Adding an existing module is done by choosing Add Existing Module.
Removing a module is done by choosing Remove Module. The current displayed module
will be removed from the project. The file will not be deleted.
On the desktop each module can be displayed on a different tab. You can hide a module
by right clicking on the tab header and choosing Hide Module.
Note that the main module cannot be hidden.
Displaying a module can be done by clicking on its name or one of its subs in the right
pane.
On the device navigating between the modules is done by choosing the module name
under the Modules menu.
Scope
By default all subs and all global variables can be accessed only within their module.
By adding the Public modifier to subs, for example:
Public Sub Trim(Str)
Match1.Value = rxTrim.Match(str)
Return Match1.String
End Sub
The specific sub will be accessible from any module.
It is also possible to declare a global variable as a public variable by replacing the Dim
keyword with Public, for example:
Sub Globals
Public someFlag
End Sub
You can also use the Private access modifier for both global variables and subs.
The behavior of the Private access modifier is exactly the same as the default behavior.
Controls and objects are public by default,
Access modules from other modules
Accessing public subs, global variables, objects or controls from a different module is
done by writing the module named followed by a period and the field name.
Forms and modules
Any number of forms can be stored in the same module.
When adding a new form you can add it to the current module or create a new module
with the new form.
It is possible to move a form from one module to another by chooising visual designer -
Tools - Move Form.
Notes
When a program starts all code under the Globals sub of each module runs first.
It is not possible to access other modules from within the Globals sub.
Only the main module can hold an App_Start sub (the first sub to run).