Results 1 to 4 of 4

Thread: freeing memory... don't understand

  1. #1

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    freeing memory... don't understand

    hi all,

    i've got something that may look a stupid question...

    when i dim an object like this:

    Dim MyVar(1000000) as string

    then at the end of the project if i want to free it like this:

    Set MyVar(1000000) = Nothing

    i get a "object still needed error" even though i'm really not using that variable and it has not been declared public...

    What am i doing wrong?

    thanks,

    w.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    hi
    Firstly, a million elements is far too small .. lets go for a billion!
    Set and Nothing are for objects not for arrays

    The correct way is...

    At top of form in declarations area
    Dim MyVar() As String 'note no number for dynamic array

    when u want to use it do...
    Redim MyVar(1000000)

    and when u want to clear it...
    Erase MyVar

    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  3. #3

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    a million, no, a billion thanks ;-)

    i do hope this is enough for memory management...

    i don't know if i need a million but this number may vary from 10 to 1000000... so i put it up at max, even i know, this does slow down everything...

    well if you do have another way to go... ;-)

    thanks for your answer!

    cheers,
    w.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    You can make it larger at run time if need be

    When you fill it, use

    VB Code:
    1. ReDim Preserve MyArr(10000)

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