Home All Groups Group Topic Archive Search About

Converting C++ code to VB2005

Author
21 Dec 2006 1:54 PM
Woo Mun Foong
Hi,

I have the following 2 structures in VC++ 6.0 that would like to be
converted to VB2005

typedef struct
{
   int iNoteIndex;              
   char caIsoCurrencyCode[4];  
   int iOrientation;         
   char caSpare[3];          
} MARS_EXTENDED_NOTE;

AND

typedef struct MarsControl
{
  int iLength;
  DWORD iStatus;
  char cInfo[36]; 
  DWORD dwUserData[4];
  char cExpInfo[128]; 
  MARS_EXTENDED_NOTE ExtendedNoteData;
  int iaExtData[64];
} MARS_CONTROL, *P_MARS_CONTROL;


Question 1:
-------------
I would like to convert the 2 structure above to VB Code.
Can I follow the guideline as below?

"int iLength" is changed to "iLength As integer"
"char caIsoCurrencyCode[4]" is changed to "caIsoCurrencyCode as string"
"DWORD iStatus" is changed to "iStatus As long"
"DWORD dwUserData[4]" is changed to "dwUserData(4) As long"
"MARS_EXTENDED_NOTE ExtendedNoteData" is changed to "ExtendedNoteData As
MARS_EXTENDED_NOTE"


Question 2
-----------
I have the following function inside the Header file of VC++

int __stdcall MarsOpen(MARS_CONTROL* pCtl,
    void (__stdcall* CallbackFunction)(MARS_CONTROL* pCtl, int iEvent));

So inside my VB2005 I do this:-

1) Declare a delegate for the Callback
    Public Delegate Function MyCallBack(ByRef MarsControl As MARS_CONTROL,
ByVal iEvent As short) As Long

2) Declare an entry point to the DLL Function
    Public Declare Function MarsOpen Lib "MEIBAC.DLL" (ByRef MarsControl As
MARS_CONTROL, ByVal pFunc As MyCallBack) As Short

3) Code MyCallBack Function inside VB2005
   Public Function MyEventHandle(ByRef aMarsControl As MARS_CONTROL, ByVal
iEvent As Integer) As short

Is my declaration of the MarsOpen function correct ?

Thank You,
mfwoo

Author
1 Mar 2007 11:30 AM
Richard
Hi I seem to have all the functions in place but I am lost on MarsOPEN where I cannot attach to the event handler!

Did you ever over come this problem?

Richard

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Author
2 Mar 2007 12:56 AM
Woo Mun Foong
Dear Richard,

Did you see my prior posting ?
Following the steps you will get MarsOpen to work without any problem.


Thank You,
mfwoo

Show quoteHide quote
"Richard" wrote:

> Hi I seem to have all the functions in place but I am lost on MarsOPEN where I cannot attach to the event handler!
>
> Did you ever over come this problem?
>
> Richard
>
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
>