Remove method
Removes a key/item pair from a Dictionary object.
Syntax
object.Remove (key)
The Remove method syntax has these parts:
Part | Description |
---|---|
object | Required. Always the name of a Dictionary object. |
key | Required. Key associated with the key/item pair that you want to remove from the Dictionary object. |
Remarks
An error occurs if the specified key/item pair does not exist.
The following code illustrates use of the Remove method.
Public Sub Start()
Dim d As Object
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
Debug.Print "Keys, before using Remove."
PrintKeys d
d.Remove "b"
Debug.Print "Keys, after removing key 'b'."
PrintKeys d
End Sub
Private Sub PrintKeys(ByVal d As Object)
Dim k As Variant
For Each k In d.Keys
Debug.Print k
Next k
End Sub
' The example displays the following output:
' Keys, before using Remove.
' a
' b
' c
' Keys, after removing key 'b'.
' a
' c
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기