Note of Using Visual Basic .NET

Function specifications

Win32API format
* Not compatible with Universal Windows Platform (UWP).

Function parameters and return value

The contents of the parameters and the return value of functions are common regardless of the development language.
Please refer to the function reference for details.

Format of function reference

Visual Basic .NET has a different data type than previous versions of Visual Basic 5.0 and 6.0.
Please be careful when using the application created in the old version.

Note of using callback function

When notifying an interrupt or a trigger by using callback function in Visual Basic .NET,
it is required to fix the callback function's memory address.

The following code is the sample to process an interrupt.
For details, please refer to the sample programs.

Declaring as global variables.

Dim gCh As GCHandle
Dim pdelegate_func As PINTCALLBACK
Dim pfunc As IntPtr

In the Load method, initializing the delegate for interrupt process, and add a reference to prevent garbage collection from being destroyed.

pdelegate_func = New PINTCALLBACK(AddressOf CallBackProc)
gCh = GCHandle.Alloc(pdelegate_func)

In the Close method, releasing the handle.

gCh.Free()

Retrieving the fixed function pointer.

pfunc = Marshal.GetFunctionPointerForDelegate(pdelegate_func)

Specifying the retrieved fixed pointer by function DioSetInterruptCallBackProc.

Ret = DioSetInterruptCallBackProc(Id, pfunc, Temp)

Note of using DioDmSetBuffer()

In Visual Basic .NET, for the buffer used for bus master transfer, it is required to add process for fixing memory address.

The following code is the sample for this process.
For details, please refer to the sample programs.

Declaring as global variables.

Dim    gCh As GCHandle
Dim    pBmBuf As IntPtr
Const  DATA_SIZE As Short = 1000 ' data size
Dim    BmBuffer(DATA_SIZE) As Integer ' data buffer

In the Load method, assigning a handle of Pinned type to the buffer.

If gCh.IsAllocated = False Then
    gCh = GCHandle.Alloc(BmBuffer, GCHandleType.Pinned)
End If

In the Closed method, releasing the handle.

If gCh.IsAllocated = True Then
    gCh.Free()
End If

Retrieving the pointer of fixed object.

pBmBuf = gCh.AddrOfPinnedObject()

Specifying the retrieved fixed pointer by function DioDmSetBuffer.

Ret = DioDmSetBuffer(Id, Direction, pBmBuf, DATA_SIZE, DIODM_WRITE_ONCE)