Results 1 to 2 of 2

Thread: dynamic memory allocation (resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    dynamic memory allocation (resolved)

    How do I allocate an array in memory dynamically and delete it?
    Also how can I declare a struct in vb and access its members?
    Last edited by abcdefg; Nov 2nd, 2003 at 01:15 PM.

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Structs in VB are called types.

    VB Code:
    1. Private Type tExample
    2.   dblVal as Double
    3.   strVal as String
    4. End Type
    5.  
    6. Dim exp as tExample
    7.  
    8. 'in a sub
    9.  
    10. exp.dblVal = 3.14159

    to create a dynamic array:

    VB Code:
    1. Dim Ary() as Byte
    2.  
    3. ReDim Ary(10)
    4.  
    5. 'if you which to not wipe the memory
    6.  
    7. ReDim Preserve Ary(20)
    8.  
    9. 'to erase..
    10.  
    11. Erase Ary 'sets this basically to ary(), don't perform bound checks on this, it'll error
    12. 'you can use safearraygetdim API though

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