Convert C++ dll function declaration to VB *RESOLVED*
Hi,
I have a C++ dll which has the following function prototype declared in it.
VB Code:
Short Int Send_RS232_Command(unsigned char, unsigned char *const, unsigned char, unsigned char *const, long)
I am trying to use this dll from VB.
Code I have so far is.
VB Code:
Option Explicit
Option Base 0
Private Declare Function Send_RS232_Command Lib "RS232V2.dll" Alias "?Send_RS232_Command@@YAFEQAEE0J@Z" _
(ByVal bBoardAddress As Byte, ByRef bTxDataArray As Byte, _
ByVal bTxDataLength As Byte, ByRef bRxDataArray As Byte, ByVal lRxDataLength As Long) As Integer
Private Sub cmdSend_Click()
Dim iRet As Integer
Dim bBoardAddress As Byte
Dim bTxDataArray(10) As Byte
Dim bTxDataLength As Byte
Dim bRxDataArray(10) As Byte
Dim lRxDataLength As Long
bBoardAddress = 1
bTxDataArray(0) = 0
bTxDataArray(1) = 1
bTxDataArray(2) = 2
bTxDataArray(3) = 3
bTxDataArray(4) = 4
bTxDataLength = 5
iRet = Send_RS232_Command(bBoardAddress, bTxDataArray(0), bTxDataLength, bRxDataArray(0), lRxDataLength)
End Sub
I get the error "Bad DLL Calling Convention".
Is this because I have incorrectly declared the function?