【.NET】Is it possible to pass structs between VB and VC++?

Marino_Y 41 Reputation points
2022-11-07T09:59:09.32+00:00

Hello,

I asked a similar question earlier(sorry for the duplication)
But, I raised another question because I wanted to separate "whether what I want to do is technically feasible".
Sorry for my bad english... Please help me.

Environment
 <Development Environment>
  VisualStudio2008(VB、VC++)
  Windows7 32bit

  <Execution Environment>
  Windows7 32bit

Under these conditions, is it technically possible to pass a structure from VB (Form(Screen)) to VC++ (DLL), and VC++ (DLL) edits and returns the structure?

Since the structure will edit the result of selecting from the DB, I want to store one to multiple items of data.

In addition, since the version will be upgraded to VisualStudio2019 in the end, it does not matter if there is even a little information related to the versions from 2008 to 2019, even if it is not VisualStudio2008.
I need some information, even if it's just a little.

Thank you.

Developer technologies C++
Developer technologies VB
{count} votes

Accepted answer
  1. RLWA32 49,536 Reputation points
    2022-11-07T20:28:30.773+00:00

    For guidance on marshalling structures between managed code (VB.Net) and unmanaged code (C++) refer to marshalling-classes-structures-and-unions


1 additional answer

Sort by: Most helpful
  1. LesHay 7,141 Reputation points
    2022-11-07T18:45:40.443+00:00

    Hi

    Somewhat similar: I had (many months ago) a VB Forms application communicating with and sending/receiving data from a Linux based set top box application written in Python.
    Basically, the process revolved around learning the structure(s) expected by the set top box, and learning how to parse the reply.
    I don't think that the fact the DLL was written in C++ would matter as the compiled code of either C++ and VB would likely be the same. What would be important is knowing what the DLL is expecting as data and what it will return. For example, I could sent requests to the set top box and receive back data in various forms. I had to know all of the formats of the requests understood by the box and, inderstand what the expected return data would be - the returned data would depend on what the request was. Of course, there were also commands sent to the box for ,amy functions of the box - these would typically result in success/failure responses.
    So, all I can say is that provided you do have an understanding of the data required to be sent and the knowlefge of what is expected in response, there is no reason that I can think of why your applications could not be communicating with each other. I do assume you do have either documentation or a source where you can reference what the DLL requires in terms of sending/receiving data.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.