IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesVB.Net  Print This     

Associative Array (VB.Net and ASP Classic Cross Reference Guide)

By Mike Prestwood

VB.Net versus ASP Classic: A side by side comparison between VB.Net and ASP Classic.

 
Data Structures
 

Data structures allow you to store and work with data. Common data structures include arrays, associative arrays, etc.

Associative Array

[Other Languages] 
A set of unique keys linked to a set of values. Each unique key is associated with a value. Think of it as a two column table. MyArray['CA'] = 'California' MyArray['AR'] = 'Arizona'

Languages Focus

Associative arrays are also known as a dictionary or a hash table in other languages.

VB.Net:   Dictionary

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
Dim States As New Dictionary(Of String, String)

States.Add("CA", "California")
States.Add("NV", "Nevada")
 
MsgBox(States("NV"))
ASP Classic:   Scripting.Dictionary

Use the scriptiing dictionary object which is available on later versions of ASP Classic (all still commonly in use).

Note: Both Access VBA and VB Classic use a collection for this but collections are not supported in ASP Classic.

Syntax Example:
Dim StateList
 
set StateList = Server.CreateObject("Scripting.Dictionary")
StateList.Add "CA", "California"
StateList.Add "NV", "Nevada"
 
Response.Write "I live in " & StateList.Item("CA")












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]