From the August 2014 Issue of Prestwood eMag
 
VB.Net Language Basics:
Associative Arrays in Visual Basic (a Dictionary)
 
Posted 6/19/2008 on 6/19/2008 and updated 11/9/2008
VB.Net Code Snippet:

KB101220

An associative array links a set of keys to a set of values. In Visual Basic, associative arrays are implemented as Dictionaries.

This code produces a message box saying "Nevada."

Syntax Example:
Imports System.Collections.Generic

Protected Sub Button1_Click(ByVal sender As Object,
              ByVal e As System.EventArgs) Handles Button1.Click
        Dim States As New Dictionary(Of String, String)

        States.Add("CA", "California")
        States.Add("NV", "Nevada")
        States.Add("OR", "Oregon")
        MsgBox(States("NV"))
End Sub
Code Contributed By Stephen Berry:
Visit Profile
www.prestwood.com For service: 916-726-5675
or support@prestwood.com
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 12/5/2021