Hi, I am new to VB.NET and have created an assembly that I reference in MS Access 2003. The problem is when I try to compile the Access database after adding in the reference I get the 'User-Defined Type Not Defined' compile error message and I believe it is something to do with the way I have written my code in .NET. All I will be doing in Access is typing a name in a form and clicking a button to display a greeting (using ShowGreeting). When the name is changed it uses the RaiseError to display a different message. Surely that should be simple!!
Below is the code, please could someone tell me what I have done wrong? Many thanks Stuart
Imports System.Runtime.InteropServices
Namespace EventSource
Public Delegate Sub NameChangedHandler(ByVal NameStr As String)
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)>
Public Interface IMyInterface
Sub NameChanged(ByVal NameStr As String)
Property GreetingName() As String
Sub ShowGreeting()
End Interface
<ComSourceInterfaces(GetType(IMyInterface))> Public Class NETTest
Public Event NameChanged As NameChangedHandler
Dim lgNameStr As String
Public Property GreetingName() As String
Get
GreetingName = lgNameStr
End Get
Set(ByVal Value As String)
lgNameStr = Value
RaiseEvent NameChanged(lgNameStr)
End Set
End Property
Public Sub ShowGreeting()
MsgBox("Hello " & lgNameStr)
End Sub
End Class
End Namespace
Below is the code, please could someone tell me what I have done wrong? Many thanks Stuart
Imports System.Runtime.InteropServices
Namespace EventSource
Public Delegate Sub NameChangedHandler(ByVal NameStr As String)
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)>
Public Interface IMyInterface
Sub NameChanged(ByVal NameStr As String)
Property GreetingName() As String
Sub ShowGreeting()
End Interface
<ComSourceInterfaces(GetType(IMyInterface))> Public Class NETTest
Public Event NameChanged As NameChangedHandler
Dim lgNameStr As String
Public Property GreetingName() As String
Get
GreetingName = lgNameStr
End Get
Set(ByVal Value As String)
lgNameStr = Value
RaiseEvent NameChanged(lgNameStr)
End Set
End Property
Public Sub ShowGreeting()
MsgBox("Hello " & lgNameStr)
End Sub
End Class
End Namespace