Option Explicit
Sub Dic()
Dim Dix As Object
Dim kee
Set Dix = CreateObject("Scripting.DIctionary")
Dix.comparemode = vbTextCompare
Dix.Add "Delhi", "India"
Dix.Add "Paris", "France"
Dix.Add "New Delhi", "India"
Dix.Add "N", "{1,2,3,4,5}"
Dix.Add "Z", "{-2,0,1,2,4}"
Debug.Print Dix.Item("Paris")
Debug.Print Dix.Item("Delhi")
Debug.Print Dix.Item("delhi")
Debug.Print Dix.Item("Z")
Debug.Print "--------------------------------------------"
For Each kee In Dix
Debug.Print kee & vbTab & vbTab & Dix.Item(kee)
Next
Debug.Print "--------------------------------------------"
''You cannot add existing Key
''To avoid Run Time Error
If Dix.Exists("Delhi") Then
Dix.Remove "Delhi"
End If
Dix.Add "Delhi", "Bharat"
Debug.Print Dix.Item("Delhi")
Dix.RemoveAll
Debug.Print Dix.Item("Delhi")
Debug.Print Dix.Count
Debug.Print Dix.items()(0)
Dix.Add "Agra", "UP"
Debug.Print Dix.Count
Debug.Print Dix.items()(1)
End Sub
Sub Dic()
Dim Dix As Object
Dim kee
Set Dix = CreateObject("Scripting.DIctionary")
Dix.comparemode = vbTextCompare
Dix.Add "Delhi", "India"
Dix.Add "Paris", "France"
Dix.Add "New Delhi", "India"
Dix.Add "N", "{1,2,3,4,5}"
Dix.Add "Z", "{-2,0,1,2,4}"
Debug.Print Dix.Item("Paris")
Debug.Print Dix.Item("Delhi")
Debug.Print Dix.Item("delhi")
Debug.Print Dix.Item("Z")
Debug.Print "--------------------------------------------"
For Each kee In Dix
Debug.Print kee & vbTab & vbTab & Dix.Item(kee)
Next
Debug.Print "--------------------------------------------"
''You cannot add existing Key
''To avoid Run Time Error
If Dix.Exists("Delhi") Then
Dix.Remove "Delhi"
End If
Dix.Add "Delhi", "Bharat"
Debug.Print Dix.Item("Delhi")
Dix.RemoveAll
Debug.Print Dix.Item("Delhi")
Debug.Print Dix.Count
Debug.Print Dix.items()(0)
Dix.Add "Agra", "UP"
Debug.Print Dix.Count
Debug.Print Dix.items()(1)
End Sub
No comments:
Post a Comment