1. Dictionary
    See also Generics. The dictionary inherits from DictionaryBase.





    Public Class cDictionary

    Inherits DictionaryBase

    Public Sub Add(ByVal oKey As Object, ByVal oItem As Object)
    Me.Dictionary.Add(oKey, oItem)
    End Sub

    Public Sub Remove(ByVal oKey As Object)
    Me.Dictionary.Remove(oKey)
    End Sub

    Public Function DoesExist(ByVal oKey As Object) As Boolean
    Return (Me.Dictionary.Contains(oKey))
    End Function

    Public Property Item(ByVal oKey As Object) As Object
    Get
    Return DirectCast(Me.Dictionary.Item(oKey), Object)
    End Get
    Set(ByVal value)
    Me.Dictionary.Item(oKey) = value
    End Set
    End Property

    End Class

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim oDictionary As New cDictionary
    With oDictionary
    .Add("111", "Jack")
    .Add("222", "Jill")
    .Add("333", "Humpty")
    .Add("444", "Dumbpty")
    .Item("555") = "Zoro"
    If .DoesExist("555") Then
    oResult = .Item("555")
    MessageBox.Show(oResult.ToString)
    End If
    End Sub
    0

    Add a comment

Blog Archive
Topics
Topics
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.