Results 1 to 5 of 5

Thread: Advanced data structures

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    13

    Advanced data structures

    Are there advanced data structures in vb6 (like maps and vectors in c++) ?

    thx.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    13

    Re: Advanced data structures

    thx man.

    For a given string (key) i want to map an integer (value)

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    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

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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
  •  



Click Here to Expand Forum to Full Width