|
-
Mar 31st, 2004, 03:17 AM
#1
Thread Starter
Frenzied Member
Convert this please [resolved]
Hi!
Could anyone please help me convert this VB code to C++ code?
VB Code:
Private Type PointUDT
X As Double
Y As Double
Z As Double
End Type
I'm making a dll in C++ to speed up my VB program a bit, but i dont really know how to recieve UDT's from C++.....
Last edited by cyborg; Mar 31st, 2004 at 10:35 PM.
-
Mar 31st, 2004, 05:44 AM
#2
Syntax
struct [<struct type name>] {
[<type> <variable-name[, variable-name, ...]>] ;
.
.
.
} [<structure variables>] ;
Example
#include <string.h>
struct my_struct {
char name[80], phone_number[80];
int age, height;
} my_friend;
void func() {
strcpy(my_friend.name,"Mr. Wizard"); /* accessing an element */
}
struct my_struct my_friends[100]; /* declaring additional variables */
-
Mar 31st, 2004, 05:24 PM
#3
Thread Starter
Frenzied Member
I'm still having problems...Here's my struct:
Code:
struct sPoint {
double X, Y, Z;
};
Here's the function in C++:
Code:
bool _stdcall CheckTriangle(sPoint A,sPoint B,sPoint C,double X,double Y)
{
if (Determinant(A.X, A.Y, B.X, B.Y, X, Y) && Determinant(B.X, B.Y, C.X, C.Y, X, Y) && Determinant(C.X, C.Y, A.X, A.Y, X, Y))
return true;
else
return false;
}
I don't have any problems compiling this code! It works fine.
It's in VB the problem is.
Here's the UDT in VB:
VB Code:
Private Type PointUDT
X As Double
Y As Double
Z As Double
End Type
Here's how i declare the function:
VB Code:
Private Declare Function CheckTriangle Lib "3d.dll" (ByRef A As PointUDT, ByRef B As PointUDT, ByRef C As PointUDT, ByVal X As Double, ByVal Y As Double) As Boolean
VB gives me this error msg: "Bad DLL calling convention"
What's wrong with this code?
-
Mar 31st, 2004, 06:03 PM
#4
Fanatic Member
Your C function should take pointers to sPoint structs:
bool _stdcall CheckTriangle(sPoint* A,sPoint* B,sPoint* C,double X,double Y)
Also, when doing C dlls for VB i always use a def file to export the functions, are you doing that?
-
Mar 31st, 2004, 06:10 PM
#5
Frenzied Member
-
Mar 31st, 2004, 06:49 PM
#6
Thread Starter
Frenzied Member
Originally posted by azteched
Your C function should take pointers to sPoint structs:
Thanks alot! Works perfect now!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|