Overview
- What Is Visual Basic?
- Visual Basic (VB) is Microsoft's rapid application development language.
It is the standard scripting language for MS applications such as Word and
Excel.
- Portability
- None.
- Pros and Cons
- Pros: easy to use and widely used; lots of support from third-party
add-ons; interpreted language. Cons: slow screen updates; interpreted
language.
- How To Get It
- Buy it from your local software shoppe.
- Libero Supports
- MS Visual Basic 3.0. Not tested with 4.0, but probably will work
unchanged.
Working With Visual Basic
- Schema: lrschema.vb.
- Program model: subroutine with arbitrary name and arguments.
- Good for: complex VB subroutines; batch programs.
- Files used/made: own work in myprog.bas; generates a
program called myprog.int.
- Module functions:
Private Sub module_function_name ()
- Private functions:
Private Sub private_function_name ()
- Naming style: any except -style=cobol.
- Limits: 999 states, events, modules. (Libero allows 1000 of
anything.) All tables are defined dynamically, at runtime.
- Development cycle: when you change the .bas source file,
you can run the VB application right away. When you change the dialog, you
must regenerate the .int and .bas files, and either stop
and restart VB, or remove and re-insert the two files from your project
Example of code
Code fragments:
'
'**************** MODULE FUNCTION NAME *****************
'
Private Sub module_function_name ()
End Sub
Private Sub private_function_name (argument,...)
the_next_event = ok_event
exception_raised = True
the_exception_event = error_event
}
A fuller example.
Notes
- Since there is no way to distinguish module functions from private
functions, the schema turns-off idle module checking.
- The .int code file is the dialog interpreter. You have to
include both the .bas and .int files in your project. I
make the split into two files so that you are not faced with the generated
code when you edit the .bas source file.
- The .int interpreter calls the .bas source file via a
dispatcher function. This function (which is generated) calls a particular
module and returns event information. This is not particularly fast, but
works okay.
- All functions are private; this allows several Liberated programs in the
same VB application.
- VB sorts functions in a source file into alphabetical order; I called the
dispatcher 'ZzDis_...' to ensure that it comes at the end. This is just for
cosmetic reasons. If for some reason the dispatcher function comes somewhere
in the middle of the source, everything will still work okay. (I have at
least one source file where VB did not arrange the functions correctly.)
Specific Schema Options
- -opt:slice=shared - the program will periodically calls DoEvents()
to allow other Windows applications to run at the same time.
- -opt:slice=exclusive - the program does not cooperate with Windows
multitasking. This is the default option.