Public Function RETURN_Equipment(Optional category As String) As Collection
Dim config As classConfiguration
Set config = New classConfiguration
Dim item As classItem
Set item = New classItem
Dim myCollection As Collection
Set myCollection = New Collection
For Each config In Configurations
For Each item In config.colItems
If IsMissing(category) Then
myCollection.add item
ElseIf InStr(category, "mainframe") <> 0 And item.category = "mainframe" Then
myCollection.add item
MsgBox "Fired!"
ElseIf category = "accessory" And item.category = "accessory" Then
Else
End If
Next
Next
RETURN_Equipment = myCollection
End Function
我不断得到
编译错误:
参数不可选
我在最后一行收到错误
RETURN_Equipment = myCollection
我理解错误消息,它告诉我我没有填写参数。但我只有一个参数,并且我已将其声明为可选。看起来代码认为我正在尝试从函数调用该函数?
是什么赋予了?
每当您分配一个对象时,您都需要使用set
关键词。
set RETURN_Equipment = myCollection
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)