DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: Map 2 strings

  1. #1
    Join Date
    Jan 2005
    Location
    UK
    Posts
    604

    Map 2 strings

    Hi,
    I wonder whether there is a Type in VB that enables me to map strings to each other (similar to the std C++ map<type1,type2>). Or do I have to implement it myself.
    An array won't do, as I want to avoid iterating through the list everytime I need an element.
    What I want to achieve is something like:

    Dim x as map ' between strings
    Dim s as String

    x.Add("Key1", "Value1")
    x.Add("Key2", "Value2")
    x.Add("Key3", "Value3")
    x.Add("Key4", "Value4")

    s = x.GetValue("Key3") ' delivers "Value3")

    Anybody got an idea?

    Cheers,

    D

  2. #2
    Join Date
    Feb 2004
    Posts
    27
    Use a collection

    Dim x As New Collection
    x.Add "value1", "key1"
    x.Add "value2", "key2"
    x.Add "value3", "key3"
    x.Add "value4", "key4"

    And MsgBox x.Item("key3") will return "value3"

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You might also look at the Scripting.Dictionary class in the Microsoft Scripting Runtime (scrrun.dll).
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Replies: 5
    Last Post: 06-19-2006, 09:48 AM
  2. Replies: 0
    Last Post: 08-28-2005, 11:36 PM
  3. Allocating memory in VB (Custom strings)
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 4
    Last Post: 03-04-2002, 07:04 AM
  4. Looking for a good site map tool
    By Woody Medina in forum Architecture and Design
    Replies: 4
    Last Post: 08-01-2001, 07:40 AM
  5. map areas not passing Form object to java script
    By mark hembree in forum ASP.NET
    Replies: 1
    Last Post: 01-11-2001, 10:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links