Consulting

Results 1 to 4 of 4

Thread: Converting 32-bit to 64-bit VBA code

  1. #1

    Converting 32-bit to 64-bit VBA code

    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.

    Declare 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" ()
    ​​​​​​​Thank you
    Last edited by Aussiebear; 10-11-2023 at 02:59 AM. Reason: Added code tags to supplied code

  2. #2

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Is the dll 64bit? If not, it won't work.
    Be as you wish to seem

  4. #4
    you mayt try to run regsvr32.exe (from SysWow64 folder) and register your dll..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •