小编Slo*_*ep_的帖子

VBA /如何检查字典项是否存在于另一个字典中?

我需要在 VBA 中有两个字典,我想检查第二个字典中是否存在第一个字典中的一项。我尝试了下面的代码,但没有找到该项目。仅出现消息“不存在”。有人可以帮忙吗?

Sub Dict()

Dim Tuna As Scripting.Dictionary
Set Tuna = New Scripting.Dictionary
Dim Pako As Scripting.Dictionary
Set Pako = New Scripting.Dictionary

Tuna.Add "01", "first"
Tuna.Add "02", "second"

Pako.Add "01", "first"

If Tuna.Exists(Pako.Items(0)) = True Then
MsgBox ("exists")
Else
MsgBox ("not exists")

End If
End Sub
Run Code Online (Sandbox Code Playgroud)

问候

arrays excel vba dictionary

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

dictionary ×1

excel ×1

vba ×1