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 event 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 the analog input event that device operation end.
For details, please refer to the sample programs.

Declaring as global variables.

Dim gCh As GCHandle
Dim pdelegate_func As PAICALLBACK
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 PAICALLBACK(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 AioSetAiCallBackProc.

Ret = AioSetAiCallBackProc(Id, pfunc, AIE_END, Temp)

Note of using AioSetAiTransferData() and AioSetAoTransferData()

In Visual Basic .NET, for the buffer used for user buffer mode, 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 pBuffer As IntPtr
Dim AiData(10000) As Integer

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

If gCh.IsAllocated = False Then
    gCh = GCHandle.Alloc(AiData, 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.

pBuffer = gCh.AddrOfPinnedObject()

Specifying the retrieved fixed pointer by function AioSetAiTransferData.

Ret = AioSetAiTransferData(Id, 10000 , pBuffer)