Instruction manual

Table Of Contents
Page
57
PC215E
Double-click on the empty Form1 design window to bring up the code window for the
Form_Load() subroutine. At runtime, this routine will get called when the program first
starts up.
Type the following lines into the Form_Load() subroutine:
hBoard = ERRSUPPORT
Load REGISTER
REGISTER.Show modal
Unload REGISTER
These lines of code will cause the Board Registration dialog box to pop up so that the
PC215E board can be registered with the DLL.
Put away the code window, and select the Form1 design window
Select 'Window|Menu Design...' to bring up the dialog box from which you design the
form's menubar. Type 'Exit' as the caption and 'mnuExit' as the name for the first
menu bar item, then click on OK to put the dialog box away.
The menubar will now appear in the Form1 design window. Click on the 'Exit' item to
bring up the code window for the mnuExit_Click() subroutine. At runtime, this routine
will get called whenever the 'Exit' menu is selected.
Type the following lines into the mnuExit_Click() subroutine:
Dim e As Integer
e = freeBoard( hBoard )
if e <> OK then
Call ReportError( e )
End If
End
These lines of code un-registers the board from the DLL as the program closes.
These eight steps will create the shell of a VB application that can now be run. The program at
this stage does nothing more than register a PC215E board (or any other board in the PC214E,
PC215E, PC212E, PC218E and PC272E series) with the DLL on start-up, and free that board
on exit.
Section 6.6 describes the library functions available. Where arguments to functions are
described as pointers, the address of a user-declared variable is required. This is taken care of
automatically by Visual Basic because all arguments to the DLL functions are passed by
reference, unless the 'ByVal' prefix is used on an argument in the function declaration in the
DLL's Visual Basic include file, DIO_TC.BAS. For example, function
TCgetCount
requires a
pointer to a variable declared as long, into which the count value result will be placed. A typical
VB code example for displaying the Z1 Counter 0 count value would be
Dim count As Long ' declare count as long
i = TCgetCount( h, Z1, 0, count )
Text1.Text = Str$( count ) ' count now contains new value