因为你还没有赋值,你只是声明了自定义类型。应该这样:
Public Type user
strUserName As String
strPassWord As String
End TypePublic Sub Main()Dim a As user
with a
.strUserName = "hello"
.strPassWord = "world"
end with
test a
End SubPublic Sub test(a As Variant)
MsgBox a.strUserName
End Sub
Public Type user
strUserName As String
strPassWord As String
End TypePublic Sub Main()Dim a As user
with a
.strUserName = "hello"
.strPassWord = "world"
end with
test a
End SubPublic Sub test(a As Variant)
MsgBox a.strUserName
End Sub
a.strusername=newvalue
msgbox a.strusername
end sub
strUserName As String
strPassWord As String
End TypePublic Sub Main()Dim a As user
With a
.strUserName = "hello"
.strPassWord = "world"
End With
test a
End SubPublic Sub test(a As user)
MsgBox a.strUserName
End Sub
public sub test(a as variant)
end sub
参数的类型在设计期是不知道的
strUserName As String
strPassWord As String
End Type添加一个标准Exe工程,添加一个module,引用新建的ActiveX DLL工程,代码如下:
Option Explicit
Public Sub Main() Dim o_udtUser As user
With o_udtUser
.strUserName = "hello"
.strPassWord = "world"
End With
test o_udtUser
End Sub
Public Sub test(ByVal udtBinding As Variant)
MsgBox udtBinding.strUserNameEnd Sub
谢谢!!