在VB中用OLE自动化的方法调用MAPINFO7.0。
Public mi As Object
Public myCallback As New Class1Private Sub Form_Load()
    Set mi = CreateObject("MapInfo.application")
    mi.Do "Set Application Window " & Form1.hWnd
    mi.SetCallback myCallback     '运行时错误!!!!!@
End Sub@行报错:属性或方法调用不能包含对私有对象的引用。可明明是用PUBLIC定义的呀。
还请行家看看,谢谢了

解决方案 »

  1.   

    你的class是不是用到自定义结构了
      

  2.   

    呵呵,多谢了,VB没怎么用过,代码是从SAMPLE拷过来的,类中方法定义
    Public Sub QueryTool(ByVal CmdStr As String)
    '....
    End Sub
    请问这样写有问题吗?
      

  3.   

    Public Sub QueryTool(ByVal CmdStr As String)
    '....
    End Sub
    这个没错,还有没有别的结构
    比如(Class1内容,两个方法一个属性):
    Option ExplicitPrivate mvarproper1 As String
    Private MyName As StringPublic Sub SetName(ByVal strName As String)
       MyName = strName
    End SubPublic Function getName() As String
    getName = MyName
    End FunctionPublic Property Let proper1(ByVal vData As String)
        mvarproper1 = vData
    End Property
    Public Property Get proper1() As String
        proper1 = mvarproper1
    End Property
    Private Sub Class_Initialize()
       MyName = "Class1"
    End Sub
    使用Private Sub Command1_Click()
    Dim mCls As New Class1
    mCls.SetName ("CSDN")
    MsgBox mCls.getName
    End Sub
    以上是没错的,但是如果class1内容这样就有错了,错误就是你上边提到的
    Private MyName As StringPrivate Type mTypeTest
       Str1 As String
       int1 As Integer
    End Type
    Private mvarproper1 As mTypeTest
    Public Sub SetName(ByVal strName As String)
       MyName = strName
    End SubPublic Function getName() As String
    getName = MyName
    End FunctionPublic Property Let proper1(ByVal vData As mTypeTest)
        mvarproper1 = vData
    End Property
    Public Property Get proper1() As mTypeTest
        proper1 = mvarproper1
    End Property
    Private Sub Class_Initialize()
       MyName = "Class1"
    End Sub