X hits on this document

140 views

0 shares

0 downloads

0 comments

14 / 37

MODBUS Communications Driver - Function QRF

Visual Basic

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.

Page 6

June 6, 1998

Revision 2.210

Document info
Document views140
Page views142
Page last viewedMon Jan 23 02:43:50 UTC 2017
Pages37
Paragraphs781
Words6172

Comments