Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual C++ 2005 ( Passing value from VB6 to C++ DLL )

Status
Not open for further replies.

C4C

Technical User
Jan 1, 2003
11
0
0
US
Hello,

First off, this is my first C++ project and as usual I have bit off more than I can chew, but that's my style of learning.

Is there any way to pass an array from VB6 to a C++ DLL function? If not is there any way to pass a value that can be used to dimension an array in the function?

I can pass the double values to the function but I cannot create an array to load them into because I have no const value with which to size an array. The DLL works just fine if I hard code the data in the program. When compared to the complexity of the DLL this issue leaves me feeling like I'm Stuck on Stupid. I have included the section of code below.

Thanks in advance for any help.

Ron Becker

/* The Array: Point_2 is a Type. */

Point_2 pts[]={Point_2(2.5849,-1.1012),
Point_2(2.4542,-.8248),
Point_2(1.7602,.6437),
Point_2(-.2112,1.2975),
Point_2(-1.388,2.0217),
Point_2(-2.7459,1.7602),
Point_2(-3.4399,.9555),
Point_2(-2.2531,.523),
Point_2(-1.388,-.8851),
Point_2(-1.9111,-2.0921),
Point_2(-.2414,-2.6956),
Point_2(.8047,-2.1927),
Point_2(1.901,-1.4283),
Point_2(2.4542,-.8248),
Point_2(2.5983,-.6676)};

/* Next Procedure: load array into vector. */

std::vector<Point_2> star(pts,pts+13);
 
Just pass the first value of the array. Since it is passed by location reference, which in C++ terms is by pointer (C++ references are not location references), C++ can access the rest of the array.

To get the size of the array use

sizeof (pts) / sizeof(pts[0])

You can do it by vectors but I have yet to try passing those to VB.
 
xwb,

Thanks for your advice. As you probably noticed the subject title did not reflect real issue. Originally I was passing the data with a string and then splitting the at "|" followed by splitting sub string at "/" and then using atof to get the double values. That works very well so I retained that part of the procedure. I enrolled in Vector 101 at cplusplus, God I love that site, and graduated at the top of my class. With that knowledge things got much easier and I now have the DLL completed. Now if I could just figure out how to edit my original post so that it showed the issue has been resolved.

Servo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top