DynaPDF Manual - Page 34

Previous Page 33   Index   Next Page 35

Language Bindings
Page 34 of 839
The right combo box contains the available events, when selecting the event "Error" VB adds
automatically an empty event procedure to your source code:
Private Sub FPDF_Error(ByVal Description As String, ByVal ErrType As
Long, DoBreak As Boolean)
' Add your code here
' To break processing after an error occurred set the variable
' DoBreak to True
End Sub
Now you can enter some code that should be executed when the event is fired. Note that you
must still create an instance of the class CPDF before a DynaPDF function can be executed (see
the example below).
Note also that VB exceptions are not used so that an error block will normally never be
executed. The following declaration has effect in the means of the DynaPDF exception handling:
On Error GoTo errPDF
' Call some DynaPDF functions...
: errPDF
If Err.Number <> 0 Then
MsgBox Err.Description
Exit Sub
End If
The error block cannot be executed because DynaPDF does never raise an exception (except the
class constructor). If an error occurred, the event "Error" is raised instead. However, there are
still cases in which a VB exception can occur, e.g. when passing an empty array to a function
that requires some values in it. So, the code should still be encapsulated in an error block. All
you need to know that this error block does not affect the normal exception handling of
DynaPDF.
The DoEvents problem
The usage of events in Visual Basic is quite easy but there is a special behaviour that must be
taken into account when developing VB applications. When using the DoEvents procedure in a
VB function you must make sure that the function cannot be executed again while a previous
call of the function is still running.
DoEvents enables the asynchronous processing of the message loop so that the user interface
can be updated and the user can execute something while a function is still running (e.g. press a
 

Previous topic: Microsoft Visual Basic 6.0, Exception handling in Visual Basic

Next topic: Visual Basic .Net, 64 Bit Applications, General Note: