When hardware events occur on the ETH32, information about that event is transmitted to your application if you have enabled it using the EnableEvent Method. When this information is received, the Eth32 class notifies your application of the event in a manner that is consistent with the way Visual Basic 6 applications typically process events. That is, the ETH32 events will be processed by your application in a manner very similar to the way that the Click event of a form's command button would be processed.
The event handler function is a function written by you, the programmer. Because it is a function you write, you have complete freedom to inspect whichever aspects of the event data you need to and react however you see fit.
In Visual Basic 6, your event handler function is executed by the same thread as the rest of your code. While this is the same situation as command button Click events or other form events, you should be aware that if some part of your code is tying up the CPU, events will not be processed until that code is done. If you ever need ETH32 events to be processed during a situation such as this, your code may call the CheckEvents Method at the time(s) that any pending events should be processed.
Your event handler function's name must start with the name of your object variable, be followed by an underscore and EventFired ('_EventFired'). The event handler must also accept a very specific set of parameters. Fortunately, Visual Basic will automatically create an empty event handler function for you. After you have declared an Eth32 object variable (see the Basic Declaration section above), there will be an entry in the Object drop-down box (the one on the left) at the top of the VB code editor. Simply select that entry and VB will automatically create an empty event handler function. Your code file may now contain something like this:
Option Explicit Dim WithEvents dev As Eth32 Private Sub dev_EventFired(ByVal id As Long, ByVal eventtype As Long, ByVal port As Long, _ ByVal bit As Long, ByVal prev_value As Long, ByVal value As Long, _ ByVal direction As Long) End Sub
The event handler receives the exact same parameters as the members of the eth32_event structure. Please see description of that structure for an explanation of their meaning. Note that the parameters are passed to the event handler individually instead of as a structure due to restrictions of the VB5/6 language.