-
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
-
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"
-
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
-
By Miha Markic in forum .NET
Replies: 5
Last Post: 06-19-2006, 09:48 AM
-
Replies: 0
Last Post: 08-28-2005, 11:36 PM
-
By Mark Alexander Bertenshaw in forum VB Classic
Replies: 4
Last Post: 03-04-2002, 07:04 AM
-
By Woody Medina in forum Architecture and Design
Replies: 4
Last Post: 08-01-2001, 07:40 AM
-
By mark hembree in forum ASP.NET
Replies: 1
Last Post: 01-11-2001, 10:21 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks