MODBUS Communications Driver - Function QRF
Visual Basic provides good support for calling external DLLs like the MODBUS Driver. To define the Driver’s function calls for your VB program you’ll need to add the file MBDEFS.BAS to your Visual Basic project.
Once the definitions file has been added to your project, you can call the Driver as you would any other function. For example, consider this code fragment:
Dim rc As Integer Dim v(64) As Integer
rc = MB_ReadInputRegisters(6, 30010, 3, v(0))
These statements will read three Input Registers starting at address 30010 from MODBUS node 6 into the array v. The Driver will return a status code (0 for success or an error code) that VB will assign to the variable rc.
If the call completes successfully, then v(0) will contain the contents of register 30010, v(1) the contents of 30011, and so on. The rest of the Driver’s functions are used in the same way.
June 6, 1998