EasyManua.ls Logo

Titan Electronics USB-2CAN-M - Using the API in Visual Basic 6.0

Titan Electronics USB-2CAN-M
76 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
69
9.6.12 Using the API in Visual Basic 6.0
1. Ensure that the DLL file is placed in the same folder as your application executable.
2. Import the functions you need from the DLL into your source code with the Declare
statement:
Private Declare Function CAN_Open Lib "CANDLL_STDCALL.dll" (ByVal
ComPort As String, ByVal szBitrate As String, ByVal acceptance_code
As String, ByVal acceptance_mask As String, ByRef Flags As Long,
ByVal Mode As Long) As Long
3. Create a definition of the CAN_MSG structure for the CAN_Write and CAN_Read
functions, if needed.
Private Type CAN_MSG
Id As Long
Size As Byte
Data(0 To 7) As Byte
Flags As Byte
Timestamp As Integer
End Type
To use the CAN_MSG structure, you will need to create an instance of the structure
you just defined.
Private myCANMSG As CAN_MSG
4. In order to communicate with the channel with other functions after opening it
with CAN_Open, you need to create a variable to store the handle value.
Private myHandle As Long
myHandle = CAN_Open(("COM3", "50", "00000000", "00000000", 1, 2)
5. This concludes the basic setup process of using the DLL in Visual Basic 6.0.
Imported functions can then be easily called form the DLL with the parameters
created above.

Table of Contents