VB6アプリケーションでCOMクラスを使用しようとしています。なんらかのラッパーを作りました。オブジェクトを作成するとメッセージが表示されるIs Nothing 1
ので、メンバー変数が設定されていてnullではないことを示していますが、プロパティを使用してこのメンバーを返そうとすると、戻り行に例外が表示されますObject variable or with block variable not set
。私はそれを修正する方法がわかりません。
// MyComClass
This is a COM class with method Operation
// clsMyCom.cls
Private WithEvents m_myComClass As MyComClass
Private Sub Class_Initialize()
If m_myComClass Is Nothing Then
MsgBox "Is Nothing 1"
End If
Set m_myComClass = New MyComClass
If m_myComClass Is Nothing Then
MsgBox "Is Nothing 2"
End If
End Sub
Public Property Get MyImplementation() As MyComClass
If m_myComClass Is Nothing Then
MsgBox "Is Nothing 3"
End If
// in this line I see exception:
// object variable or with block variable not set
MyImplementation = m_myComClass
End Property
// usage
Dim variable As clsMyCom
Set variable = New clsMyCom
Call variable.MyImplementation.Operation(...)
メソッドを次のように変更します。
Public Property Get MyImplementation() As MyComClass
If m_myComClass Is Nothing Then
MsgBox "Is Nothing 3"
End If
// in this line I see exception:
// object variable or with block variable not set
Set MyImplementation = m_myComClass
End Property
明確にするために、あなたは逃した Set
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加