the dictionary object stores data as key item


The Dictionary object stores data as key, item pairs. A Dictionary object is the corresponding of a PERL associative array. Items, that can be any form of data, are stored in the array. Each item is related with a unique key. The key is utilized to retrieve an individual item & is an integer or a string usually, however can be anything except an array.

The following code shows how to create & use a Dictionary object:

Dim d  'Create a Script Level variable

Set d = CreateObject("Scripting.Dictionary")

Sub cmdAdd_OnClick

d.Add "0", "Amar"     'Add some keys and items d.Add "1", "Bunty"

d.Add "2", "Chaman"

a = d.items

For i = 0 To d.Count document.frmForm.Elements(i).Value = a(i)

Next

End Sub

Sub cmdExist_onClick

d.Add "a", "Amar"     'Add some  keys and items. d.Add "b", "Bunty"

d.Add "c", "Chaman" If d.Exists("c") Then

msgbox "C key exists."

Else

msgbox "C key does not exist." End If

End Sub

Sub cmdKey_onClick

d.Add "a", "Amar"     'Add some keys and items. d.Add "b", "Bunty"

d.Add "c", "Chaman"

d.Key("c") = "d"        'Set key for "c" to "d". End Function

End Sub

Sub cmdKeys_onClick

d.Add "a", "Amar"     'Add some  keys and items. d.Add "b", "Bunty"

d.Add "c", "Chaman" a = d.keys

For i = 0 To d.Count document.frmForm.Elements(i).Value = a(i)

Next

End Sub

Sub cmdRemove_onClick

d.Add "a", "Amar"     'Add some  keys and items. d.Add "b", "Bunty"

d.Add "c", "Chaman"

d.Remove("b")

a = d.keys

For i = 0 To d.Count document.frmForm.Elements(i).Value = a(i)

Next

End Sub

Sub cmdCompareMode_onClick d.CompareMode = vbTextCompare

d.Add "a", "Amar"      'Add some keys and items. d.Add "b", "Bunty"

d.Add "c", "Chaman"

d.Add "B", "Baltimore"   'Add method fails on this line because the

'letter b exists already in the Dictionary.

End Sub

Request for Solution File

Ask an Expert for Answer!!
Visual Basic Programming: the dictionary object stores data as key item
Reference No:- TGS0415584

Expected delivery within 24 Hours