I am using the Aardvark I2C/SPI Host Adapter with an Excel VBA (32-bit Excel) script. I have questions about using the function aa_i2c_read for data arrays:
If I have the array of data_in defined in Integer type (i.e. Dim data(512) As Integer), would I have the problem to pass my data array of Integer type to ByRef data_in() As Byte defined in the function?
Thanks for your question! The VB6 aardvark.dll can be directly used, as it uses the same data as VBA. For more information, please refer to this article about data types in VBA and .NET.
Note: This example was created for 32-bit Excel; 32-bit Aardvark VB6 DLL was used.
Private Declare Function vb6_aa_find_devices Lib "C:\User\Downloads\aardvark-api-windows-i686-v5.15\aardvark-api-windows-i686-v5.15\vb6\aardvark.dll" (ByVal num_devices As Long, ByRef devices As Integer) As Long
Sub Button2_Click()
Dim num As Long
Dim devices(15) As Integer
Dim nelem As Long
num = vb6_aa_find_devices(16, devices(0))
End If
End Sub
There are more code examples in the VB6 folder. These 32-bit Aardvark API scripts can be used as-is or modified for your specifications. This folder also has a VBA example that is equivalent to aalights.c, which integrates VB6 dll with VBA. This example uses the I2C/SPI Activity Board. The GPIO lights on the Activity Board flash when you click Button 1 in the Excel sheet.
You can see the VBA code behind the button click event. To do so, right-click the Button 1 on the Excel sheet, and then Select Assign Macro and Edit.
We hope this answers your questions. Additional resources that you may find helpful include the following:
If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.