|
-
Sep 9th, 2007, 01:55 AM
#1
Thread Starter
New Member
Advanced data structures
Are there advanced data structures in vb6 (like maps and vectors in c++) ?
thx.
-
Sep 9th, 2007, 03:52 AM
#2
Re: Advanced data structures
Welcome to the forums. 
Not in the same sense that you might be used to. What are you looking to accomplish?
-
Sep 9th, 2007, 09:54 AM
#3
Thread Starter
New Member
Re: Advanced data structures
thx man.
For a given string (key) i want to map an integer (value)
-
Sep 9th, 2007, 07:06 PM
#4
Re: Advanced data structures
I'm not sure if this is quite what you are looking for but a Collection might do...
Code:
Option Explicit
Dim MyCollection As Collection
Private Sub Form_Load()
Set MyCollection = New Collection
With MyCollection
.Add CInt(123), "Tom"
.Add CInt(456), "Dick"
.Add CInt(789), "Harry"
End With
End Sub
Private Sub Command2_Click()
With MyCollection
.Remove "Harry"
.Add CInt(666), "Harry"
End With
End Sub
Private Sub Command1_Click()
With MyCollection
Debug.Print .Item("Tom")
Debug.Print .Item("Dick")
Debug.Print .Item("Harry")
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set MyCollection = Nothing
End Sub
-
Sep 9th, 2007, 10:32 PM
#5
Re: Advanced data structures
You can also link numbers as keys, but you must force them to Strings:
Code:
MyCollection.Add "Harry", CStr(666)
VB is unable to coerce values and other data to collection keys, so it must be done explicitly.
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
|
Click Here to Expand Forum to Full Width
|