nima1985 Posted July 12, 2005 Posted July 12, 2005 Hi, I have c++ code which I wrapped (so it's being used as a dll), and I call the functions in vb.net. The C++ code calls functions (which work, coz I tested it in other programs) from a PCI card hooked up to the CPU. In C++ the function which I call is: extern "C" __declspec( dllexport ) int _stdcall GPS637Time(float *time, float *week) { UCHAR getpacket[80], sendpacket[80]; // Receive buffer GpsPkt receive; GpsPkt send; int n; int s; send.len = 1; send.id = 0x37; send.data =sendpacket ; receive.len = 20; receive.id = 0x41; receive.data = getpacket; s = bcGPSMan (&send, &receive); for (n=0;n!=100;n++){ if (s!=RC_ERROR) break; s = bcGPSMan (&send, &receive); } if (s == RC_OK) { *time = (float)(convertf(&getpacket[0])); *week=(float)(convertf(&getpacket[4])); return RC_OK; } return RC_ERROR; } bcGPSMan(..) is from the PCI card. the helper function is: float convertf (char *s) { union { float f; char uc[4]; } fconv; fconv.uc[3] = *(s++); fconv.uc[2] = *(s++); fconv.uc[1] = *(s++); fconv.uc[0] = *s; return fconv.f; } In VB.NET, I declare the dll function: Private Declare Function GPS637Time Lib "GPS637Wrapper.dll" (ByRef time As Single, ByRef week As Single) As Long And call it: Dim ok As Long ok = GPS637Time(time, week) Where I get the above error message. Can ANYONE pleaseeeeeee help me? :-\ Thank You!! :) Quote
nima1985 Posted July 12, 2005 Author Posted July 12, 2005 Thanks for the reply. I made "ok" be an Integer, and I made the declaration for the function return an Integer. It still causes the error. I think it might have something to do with the parameters. I tested the c++ code using just c++, and sending pointers to the function. I think the way I send variables in vb.net is incorrect. :s I'm not sure wut to do next.. How else can i send the variables in vb.net?? :confused: Quote
techmanbd Posted July 12, 2005 Posted July 12, 2005 ok = GPS637Time(time, week) time and week. Where did you declare them and how did you declare them? Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
nima1985 Posted July 12, 2005 Author Posted July 12, 2005 I declared them in vb.net right before the GPS637Time(..) function. Dim time, week as Single I even tried to create new objects with time and week but it still created the error: time = new Single week = new Single Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.