Are there advanced data structures in vb6 (like maps and vectors in c++) ?
thx.
Printable View
Are there advanced data structures in vb6 (like maps and vectors in c++) ?
thx.
Welcome to the forums. :wave:
Not in the same sense that you might be used to. What are you looking to accomplish?
thx man.
For a given string (key) i want to map an integer (value)
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
You can also link numbers as keys, but you must force them to Strings:VB is unable to coerce values and other data to collection keys, so it must be done explicitly.Code:MyCollection.Add "Harry", CStr(666)