用VB写了个ACTIVE.dll(名字是XTDSLIMPORTDATE.dll)
VB中写了下面的代码
ShowForm.class代码:
Private mvartest As Integer
Public Property Let test(ByVal vData As Integer)
    mvartest = vData 
End Property
Public Property Get test() As Integer
    test = mvartest
End PropertyPublic Sub ShowLMForm()
    Frm_AddDate.Show 1
End SubFrm_AddDate.form代码
Private mShowForm As New ShowForm
Private Sub CmdToCount_Click()mShowForm.test = tTPartPicNO.Text
msgbox mShowForm.testExit Sub
handlerr:
Debug.Print Err.Description
End SubVC代码:
#import "C:\e-tech\Xtpdm35\pdm\XTDSLIMPORTDATE.dll" no_namespace _ShowFormPtr showForm;
HRESULT showFormhr = showForm.CreateInstance(__uuidof(ShowForm));
showForm->ShowLMForm();
//运行到上面都没有错误.vb中的ShowLMForm方法可以执行。
现在的问题是我如何才能实现vb中的Public Property Get test() As Integer这个方法
用showForm->Gettest();获取编译可以通过但用quickwitch查看会有下面提示
CXX0063:ERROR:overloaded operator->not supported

解决方案 »

  1.   

    quck watch不对,那么实际的值对吗?
    int a = showForm->Gettest();
    如果这样对,就不管它了呀。
      

  2.   

    这是我做的一个例子。你参照一下。
    VB6.0
    Public Function MyVBFunction(x As Integer) As Integer
     MsgBox x
    End Function
    Public Function MyVBFunction2(s As String) As String
    MyVBFunction2 = s & "、返却値は文字列です。"
    End Function
    Public Function MyVBFunction3(x As Integer) As String()
    Dim s(0 To 10) As String
    s(0) = "12345"
    s(1) = "67890"
    s(2) = "ABCDE"
    MyVBFunction3 = s
    End Function//////////////////////////////////////////////////////////
    VC++6.0
    #include <stdio.h>
    #include <afx.h>#include <iostream>
    #include <stdlib.h>
    #include <string>#include "atlbase.h"
    #include "comutil.h"#import "c:\project1.dll"  no_namespace void main()
    {
    BSTR bstrDesc; try
    {
    CoInitialize(NULL);
    short st = 2;
    short st1;
    _bstr_t  st2;
    //_bstr_t st3[10];
    SAFEARRAY  *st3; _Class1Ptr ptr; ptr.CreateInstance(__uuidof(Class1)); //1.整数返却値
    st1 = ptr->MyVBFunction(&st); //2.文字列返却値
    st2 = ptr->MyVBFunction2(&st);
    CString s;
    s.Format(_T("%s"), (LPCTSTR)st2);
    printf(s);
    printf("\n"); //3.文字列配列の返却値
    st3 = ptr->MyVBFunction3(&st); long lIndex;
    BSTR   szBSTRName; for(lIndex=0;lIndex<3;lIndex++)
    {
    SafeArrayGetElement(st3,   &lIndex,   &szBSTRName);
    ::MessageBoxW( NULL, szBSTRName, L"てすと", MB_OK ); char   charVal[10] = "";   
    WideCharToMultiByte(CP_ACP,0,szBSTRName,-1,charVal,10,NULL,NULL); printf(charVal);
    printf("\n");
    } }
    catch(_com_error &e)
    {
    bstrDesc = e.Description(); } CoUninitialize();
      }