Test your Ears: VB-software
This document describes the software architecture for the TestYourEars PC-program.
The
program is written in Microsoft Visual Basic Version 6, and uses
only Forms and Modules.
| Module / Form name | Function |
| TyE_ModMain.BAS | Startup routines work in close co-operation with the System Form. |
| TyE_Frm_System.FRM | Initialisations. System settings. Language selection, Job selection. |
| TyE_FrmAttenuatorPanel.FRM | Communication with the Attenuator Unit. Other modules communicate by setting / inspecting global variables. This form normally does not show. It can be used for diagnostics of the hardware / firmware of the Attenuator Unit. |
| TyE_FrmDirSelection.FRM | Lets the user select a directory path. |
| TyE_FrmTestComPort.FRM | Tests the existence of a serial com-port. Never shows. Keep in mind that USB serial ports only exist when the USB device is connected |
| TyE_FrmLogDisplay.FRM | Graphic display with 3-decade logarithmic
frequency axis and lineair vertical scale. Used for the test of the Hearing Threshold. |
| TyE_FrmThreshold.FRM | Performs the tests for the Hearing Threshold. |
| TyE_FrmAbxTest.FRM | Performs an A-B-X test between 2 arbitrary sound files. |
| TyE_ModIniFile.BAS | Read/write Init-file, Logfile, Calibration file. Contains declarations for the variables that are to be saved in the Ini-file. |
| TyE_ModGlobals.BAS | Variables and types that need to be global. |
| TyE_ModMath.BAS | Some Math functions. |
| TyE_ModLanguage.BAS | Reads the selected language file. Can be queried for textual messages in the selected language. |
| TyE_ModLogging.BAS | Performs the logging operations. |
| TyE_ModWaves.BAS | Routines to generate sound files in .WAV format. |
| TyE_Init.TXT |
Initialisation file. Will be written
on program exit. Most settings will be retained for the next use
of the program. |
| TyE_Standard Threshold.TXT | Data for the standard Human Hearing Threshold. File format: Per line comma separated: Frequency, value in dB. |
| xxx.cal | Headphones Calibration File. xxx may be any name. File format: Per line comma separated: Frequency, value in dB |
| TyE_Lang_Eng.LNG | Language file English (USA-UK) |
| TyE_Lang_NL.LNG | Language file Dutch (Netherlands) |
| Test.WAV | Temporary sound file for the Hearing Threshold test. Will be removed on program exit. |
| TestYourEars.EXE | The executable file. |
| 02.ico | The icon used on the forms. |
| jjjj-mm-dd-hh-mm-ss.LOG | Logfiles as generated by the program when logging is on. The name represents the system date and time on which the program was started. |
| jjjj-mm-dd-hh-mm-ss.TXT | Test results if they are written to disk. The name represents the system date and time on which the file was saved. |
| jjjj-mm-dd-hh-mm-ss.BMP | Graphical result of a Hearing Threshold test. The name represents the system date and time on which the file was saved. |
| TestYourEars.VBP | The Visual Basic Project File, describing the components in the project. Click on this file to start working on the code. Note that you may need to add some controls to the Development Environment wich are not standard there. These are: Microsoft Comm Control 6.0, Microsoft Common Dialog Control 6.0 (SP6) and Microsoft Multimedia Control 6.0. Click Project and than Components. Check these items in the list and click Apply. |
| TestYourEars.VBW | A Visual Basic Project File, keeping track where the component windows were on your screen. |
| #DelLogs.bat | Deletes all logfiles from the current directory. |
Some coding conventions I tried to use.
- Set
the "Option Explicit" switch in all modules and forms. This prevents
you from creating unintended variables because of a typo.
- Use
clear and meanigfull names for controls, constants, types, variables,
functions and so on. Yes, this may result in long names, but the
clearity will pay off if you want to change something after a year or
so, and have to find out again how it works.
- Use prefixes
for controls. Butt for Command Button, Tbx for Textboxes, Lbl for
Label, Opt for Option buttons (radio buttons) , Cbx for
Checkboxes etc. This eases the reverse engineering you will have to do
when you want to change something after a year or so.
- Use Capitalisation for Each
major Syllable
and start declaring the VariableName. If you later use that name, type it in
lowercase. If you did it right the VB editor will convert it to your
original capitalisation. If not you probably made a typo. This works
with nearly all namegiving, but not for names declared in an Enum
statement.
- Use
identation, but do not overident. Make sure that keywords which belong
together like If, Else and End If are on the same identation level.
This helps dramatically in writing code "first time right"
- Do
not fear some "Goto" 's. Especially in error trapping and -handling
routines the Goto is a blessing. If you would write those in
If-Then-Else or Select-Case constructs you easily end up with an unreadable complexity
of nested conditionals.
Some textbooks rigorously forbid the use of Goto. Such books were written by people who never had to write programs which handle input from real humans making real errors.