Option Explicit Public bln_busy As Boolean Public bln_success As Boolean Public bln_readword As Boolean Public Declare Function timeGetTime Lib "winmm
dll" () As Long Public Sub tran_modbus_order(ByVal byt_slv_id As Byte, ByVal byt_func As Byte, ByVal addr As Long, byt_data() As Byte) Dim trans_byte() As Byte Dim i As Integer Dim j As Integer Dim k As Integer Dim Index As Integer Dim CRC() As Byte Dim temp As Integer Dim lenth As Integer Dim lenth1 As Integer Select Case byt_func Case 1 ReDim trans_byte(7) As Byte trans_byte(0) = byt_slv_id trans_byte(1) = 1 trans_byte(2) = (addr - 1) \ 256 trans_byte(3) = (addr - 1) Mod 256 trans_byte(4) = 0 trans_byte(5) = byt_data(0) CRC = CRC16(trans_byte) trans_byte(6) = CRC(0) trans_byte(7) = CRC(1) Case 3 ReDim trans_byte(7) As Byte trans_byte(0) =