
Problem Connecting VB front end to C++ back end
I am trying to pass a VB user-defined to a C language function in a
dll that will send this VB user-defined type (which corresponds to a
C structure) via a socket to the C++ server. I can call a void function
in the dll and get a return value just fine. the minute I try to use a
user defined type as a parameter, I get run-time errors.
I could use strings with some char as a delimiter but I want to use
well defined message structures like you would in any C/C++
application.
In my Module.bas file:
-----------------------------
Public Const MAX_USER_NAME_LEN = 25 + 1
Public Type StdMessageHeader
TotalMessageLength As Long
MessageType As Long
MessageSubType As Long
MessageVersion As Long
TransactionId As Long
SenderPid As Long
SenderAppId As Long
DestAppId As Long
SendingUserName As String * MAX_USER_NAME_LEN
SendingHostName As String * MAX_USER_NAME_LEN
End Type
Public MYLogin As StdMessageHeader
Public Declare Function SendData Lib "CygnSock" (ByRef StdMessageHeader) As
Integer
In my pushbutton to send data:
-----------------------------------------
Private Sub LoginBut_Click()
Dim Status As Integer
MYLogin.TotalMessageLength = 84
MYLogin.MessageType = 1
MYLogin.MessageSubType = 1
MYLogin.SendingUserName = "JEFF" + Chr(0)
MYLogin.SendingHostName = "PROZAC" + Chr(0)
Status = SendData(MYLogin)
End Sub
I get a run time err:
-------------------------
Only user-defined types defined in public object modules can be coerced to
or from a variant or passed to late bound functions.
I don't understand what the compiler is asking me to do, any ideas?
Thanks,
Jeff