Collection Examples

Collection Hash Table Example

Imports System
Imports System.Collections.Generic
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms

Namespace CollectionHashtableExample
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim weeks As Hashtable = New Hashtable()
            weeks.Add("1", "SunDay")
            weeks.Add("2", "MonDay")
            weeks.Add("3", "TueDay")
            weeks.Add("4", "WedDay")
            weeks.Add("5", "ThuDay")
            weeks.Add("6", "FriDay")
            weeks.Add("7", "SatDay")
            MessageBox.Show(weeks("5").ToString())

            If weeks.ContainsValue("TueDay") Then
                MessageBox.Show("Find")
            Else
                MessageBox.Show("Not find")
            End If

            weeks.Remove("3")

            For Each day As DictionaryEntry In weeks
                MessageBox.Show(day.Key & "   -   " & day.Value)
            Next

            If weeks.ContainsValue("TueDay") Then
                MessageBox.Show("Find")
            Else
                MessageBox.Show("Not find")
            End If
        End Sub
    End Class
End Namespace

┬ęCopyright 2016 All Rights Reserved LearnDotNetHome.com