phpのissetのようなもの
vbaにはないので作りました。
Public Function isset(ByRef dic As Dictionary, ByVal KeyArr As Variant, Optional ByVal StartIndex As Integer) As Boolean
On Error GoTo handler
If dic.Exists(KeyArr(StartIndex)) Then
If UBound(KeyArr) = StartIndex Then
isset = True
Else
isset = isset(dic(KeyArr(StartIndex)), KeyArr, StartIndex + 1)
End If
Else
isset = False
End If
Exit Function
handler:
isset = False
End Function
呼び出し方
Private Sub testisset()
Dim a As New Dictionary
a.Add "b", New Dictionary
a("b").Add "c", New Dictionary
Debug.Print isset(a, Array("b", "c")) ' true
Debug.Print isset(a, Array("b", "c", "d")) ' false
End Sub