别的dll文件中有一个类,源代码如下:
Public Class person
Public ID As String
Public name As String
Public sex As String
Public birthday As Date
Public Function getName(ByVal per As person) As String
Return Me.name
End Function
Public Sub New(ByVal xID As String, ByVal xName As String, ByVal xSex As String, ByVal xBirthday As String)
Me.ID = xID
Me.name = xName
Me.sex = xSex
Me.birthday = xBirthday
End Sub
End Class
在全局代码中这样声明:
<DLLImport("classlibrary1.dll",CharSet:=CharSet.Ansi,CallingConvention:=CallingConvention.Cdecl)> _
Public Function getName(ByVal per As person) As String
End function
窗口中按钮click代码如下:
Dim you As person
you = new person("100","老张","男",#5/17/1990#)
messagebox.show((you.getName(you)))
问题是:
1、如果直接将以上dll的源代码放进全局代码,命令窗口的代码可以成功运行。
2、如果以引用dll的方式编译全局代码会失败,提示为:未定义类型 person
请教:该如何以dll引用的方式来实现?
附上项目