Dear,
I have a VBA program in Excel that communicates to a PLC. The original VBA code runs on Windows 32 bits.
We changed the PC to a 64-bit, and the code no longer runs. I included the most basic one, which is the inclusion of PtrSafe after Declare, but even so it gives an error, saying it can't find the dll (which is properly placed in the correct folder).
Could anyone tell me what I can do to fix it?
The only change I made from the 32-bit code to the 64-bit code was the inclusion of PtrSafe.
Thank youDeclare PtrSafe Function OpenModbusSerial Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal conn_num As Long, ByVal baud_rate As Long, _ ByVal data_len As Long, ByVal parity As Byte, ByVal stop_bits As Long, ByVal modbus_mode As Long) As Long Declare PtrSafe Sub CloseSerial Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal conn_num As Long) Declare PtrSafe Function OpenModbusTCPSocket Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal conn_num As Long, ByVal ipaddr As Long) As Long Declare PtrSafe Sub CloseSocket Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal conn_num As Long) Declare PtrSafe Function RequestData Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal comm_type As Long, ByVal conn_num As Long, ByVal slave_addr As Long, _ ByVal func_code As Long, ByRef buf As Byte, ByVal DataLen As Long) As Long Declare PtrSafe Function ResponseData Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal comm_type As Long, ByVal conn_num As Long, ByRef slave_addr As Long, _ ByRef func_code As Long, ByRef buf As Byte) As Long Declare PtrSafe Function ReadSelect Lib "C:\DMT 2.0\Include\DMT.dll" (ByVal conn_num As Long, ByVal time_msec As Long) As Long Declare PtrSafe Function GetLastSerialErr Lib "C:\DMT 2.0\Include\DMT.dll" () As Long Declare PtrSafe Sub ResetSerialErr Lib "C:\DMT 2.0\Include\DMT.dll" () Declare PtrSafe Function GetLastSocketErr Lib "C:\DMT 2.0\Include\DMT.dll" () As Long Declare PtrSafe Sub ResetSocketErr Lib "C:\DMT 2.0\Include\DMT.dll" ()



Reply With Quote
