"what is data type conversion between VB and VC++"

Hi everyone,
I created a project in VC++ (Class Library project in visual studio 2005) and I would like to use it in VB .
I defined 2 functions in classlibrary that one of them uses simple data type such as int,bool,.. in input and return value and other one uses data type such as char * .
When I use simple data type ,there is not any problem and I can call the function in vb successfully but when I use another data type such as (char * ,..)I can not call it and even I can not see the function in vb.
My question is about data type conversion between VC++ and VB.
My code is same as below :
//==============================
MyClassLibrary.h
#pragma once
using namespace System;
namespace MyClassLibrary{
public ref class InitCard
{
public :
bool VerifyPin(char *) ; //I can not see this function in VB
bool SetCardAccessKey(int); //I can see and use this function in VB successfully .
};
}
//======================My VB code is same as below :
Imports MyClassLibrary
Dim Jvm_offcard As New MyClassLibrary.InitCard
Jvm_offcard.SetCardAccessKey(2);
//Jvm_offcard.VerifyPin("1234") //there is an error on this line

I would like to know how can I use data type such as (char *,byte array ,string) between VC++ and VB code.
I would appreciate for any help .
Yours sincerely,
Orchid

Comments

  • : Hi everyone,
    : I created a project in VC++ (Class Library project in visual studio 2005) and I would like to use it in VB .
    : I defined 2 functions in classlibrary that one of them uses simple data type such as int,bool,.. in input and return value and other one uses data type such as char * .
    : When I use simple data type ,there is not any problem and I can call the function in vb successfully but when I use another data type such as (char * ,..)I can not call it and even I can not see the function in vb.
    : My question is about data type conversion between VC++ and VB.
    : My code is same as below :
    : //==============================
    : MyClassLibrary.h
    : #pragma once
    : using namespace System;
    : namespace MyClassLibrary{
    : public ref class InitCard
    : {
    : public :
    : bool VerifyPin(char *) ; //I can not see this function in VB
    : bool SetCardAccessKey(int); //I can see and use this function in VB successfully .
    : };
    : }
    : //======================My VB code is same as below :
    : Imports MyClassLibrary
    : Dim Jvm_offcard As New MyClassLibrary.InitCard
    : Jvm_offcard.SetCardAccessKey(2);
    : //Jvm_offcard.VerifyPin("1234") //there is an error on this line
    :
    : I would like to know how can I use data type such as (char *,byte array ,string) between VC++ and VB code.
    : I would appreciate for any help .
    : Yours sincerely,
    : Orchid
    ----------------------------------------------------------------------

    Hi,

    I don't know C++ but if you can use a VARIANT data type in the C++ and the VB then that may solve your problem.

    VARIANT is an object that can vary it's datatype i believe, and i think this happens automatically in the background.

    What is the * for after the Char as in (Char *) ?

    Why not do the PIN as an Integer or LongInteger.

    In Vb i believe it is>>

    UInt32 'unsigned or
    Int32 'for a signed Integer

    E.G.

    Dim myInt1 As Uint32
    Dim myInt2 As Int32 'or
    Dim myInt3 As Long



    Regards,

    Dr M.

  • Hey,

    I'm affraid your problem is not with the datatypes. If I am correct you'll need to do something with 'exporting' your class through COM. There are special ways of defining the interfaces for a COM object.
    If you are using VB6 an VC6++ (which you probably are) you'll need to handle it this way, since that's the way VB handles classes.
    One could probably write a book full on COM and I am certainly no expert on it.

    Good luck
    Best Regards,
    Richard

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories