我有这个功能:
template <typename T>
struct is_bananas<T, value_void_t<T::config::num_items>>
: std::true_type {};
Public Function nextBlock(featureBlockObj As FeatureBlock, endFeatureNumber As Variant) As FeatureBlock
Dim downstreamFeatureNumber As Variant
'get the feature number that this endpoint connects to
downstreamFeatureNumber = featureBlockObj.connectedFeatureNumber(endFeatureNumber)
'if it connects to a feature number, look that feature number up in blockDict
If isNumericNonBlank(downstreamFeatureNumber) Then
Set nextBlock = blockDict(downstreamFeatureNumber)
'if it does not connect, this is the last block in the sequence
Else
Set nextBlock = Nothing
End If
End Function
是字典; blockDict
是用户定义的类。
此行:
FeatureBlock
抛出错误:
Set nextBlock = blockDict(downstreamFeatureNumber)
我已验证以下内容:
Object required.
作为downstreamFeatureNumber
中的密钥存在blockDict
是blockDict(downstreamFeatureNumber)
类型的对象那我为什么不能使用FeatureBlock
将blockDict()
引用分配给nextBlock
?
答案 0 :(得分:1)
很明显,blockDict(downstreamFeatureNumber)
没什么,这是您的问题。在尝试分配给nextBlock
之前,您需要先对其进行限定(如果不应该发生,那么这将是一个完全不同的问题-不是VBA问题)。
If isNumericNonBlank(downstreamFeatureNumber) _
AND (Not (blockDict(downstreamFeatureNumber) Is Nothing)) Then