Visual Basic .NET

It is an example program in Visual Basic .NET. The conversion data and error contents are displayed in debug window.
Example program by using AioSingleAo

Example program by using AioMultiAo


Example program by using AioSingleAo

'---------------------------
' Variable declaration
'---------------------------

Dim Ret As Integer                     'Return values of functions
Dim Id As Short                        'ID
Dim ErrorString As String = Space(256) 'Array for storing error string

'---------------------------
' Initialize device
' Devicename : Aio000
'---------------------------

Ret = AioInit("Aio000", Id)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioInit : " + ErrorString)
   Exit Sub
End If

'---------------------------
' Set analog output range
' Range : -10 to 10V
'---------------------------

Ret = AioSetAoRangeAll(Id, PM10)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioSetAoRangeAll : " + ErrorString)
   Ret = AioExit(Id)
   Exit Sub
End If

'---------------------------
' Analog output form the specified channel only once
' Output channel : 0
' Output data : 800H
'---------------------------

Ret = AioSingleAo(Id, 0, &H800)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioSingleAo : " + ErrorString)
   Ret = AioExit(Id)
   Exit Sub
End If
System.Diagnostics.Trace.WriteLine("Channel0 : &H800")

'---------------------------
' Device exit
'---------------------------

Ret = AioExit(Id)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioExit : " + ErrorString)
   Exit Sub
End If


Example program by using AioMultiAo

'---------------------------
' Variable declaration
'---------------------------

Dim Ret As Integer                     'Return values of functions
Dim Id As Short                        'ID
Dim ErrorString As String = Space(256) 'Array for storing error string
Dim AoData(8) As Integer               'Conversion data
Dim i As Short

'---------------------------
' Initialize device
' Devicename : Aio000
'---------------------------

Ret = AioInit("Aio000", Id)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioInit : " + ErrorString)
   Exit Sub
End If

'---------------------------
' Set analog output range
' Range : -10 to 10V
'---------------------------

Ret = AioSetAoRangeAll(Id, PM10)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioSetAoRangeAll : " + ErrorString)
   Ret = AioExit(Id)
   Exit Sub
End If

'---------------------------
' Analog output from multiple channels only once
' Number of output channels : 8
'---------------------------

For i = 0 To 7
   AoData(i) = i * 100
   System.Diagnostics.Trace.WriteLine("Channel" + i + " : " + AoData(i))
Next i

Ret = AioMultiAo(Id, 8, AoData(0))
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioMultiAo : " + ErrorString)
   Ret = AioExit(Id)
   Exit Sub
End If

'---------------------------
' Device exit
'---------------------------

Ret = AioExit(Id)
If Ret <> 0 Then
   AioGetErrorString(Ret, ErrorString)
   System.Diagnostics.Trace.WriteLine("AioExit : " + ErrorString)
   Exit Sub
End If