Results 1 to 8 of 8

Thread: Clearing variables

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    22

    Clearing variables

    How can I clear a variable out of my memory, so that the variable no longer exist in the Windows memory ? I need this because somtimes my app gives an error that a variable causes.

    Tnx 4 help

  2. #2
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    I dont think you can in VB. All i can think of is setting the variable = nothing...but that wont get rid or it.
    You just proved that sig advertisements work.

  3. #3
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    Qtn is a bit broad. Depends on type of variable and where declared. Is it an array? Long piece of text?

    If u declare within a subroutine it is cleared as soon as sub ends
    If u declare within a form is cleared when form unloaded
    If declared publicly is always available
    If string declared as variable length eg Dim S as String then just set S = "" to clear
    If array declared as variable length eg Dim A() as Integer then just Erase A to recover memory
    There are oodles of answers. Can u maybe repost and give more details
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  4. #4

    Re: Clearing variables

    Originally posted by Junni
    How can I clear a variable out of my memory, so that the variable no longer exist in the Windows memory ?
    You can't technically. All you can do is make it a null pointer (in VB, the keyword Nothing), and the VBVM will decide whether to do garbage collection.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    22
    QUOTE
    If u declare within a subroutine it is cleared as soon as sub ends
    If u declare within a form is cleared when form unloaded
    If declared publicly is always available
    If string declared as variable length eg Dim S as String then just set S = "" to clear
    If array declared as variable length eg Dim A() as Integer then just Erase A to recover memory
    END OF QUOTE

    It's all of this I'm afraid. But I think that the problem is the public variables. I'll try all of this !

    Tnx

  6. #6
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi Junni
    Can u pls post the type of error that occurs and what line it occurs on? Hopefully this will give us more of an idea what the problem is.
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Belgium
    Posts
    22
    Beachbum: tnx 4 helping me, but if I must explain it, then I have to explain my entire program. :-)

    It's just that I put a validation on a textbox (where a number is filled in), so that the number does not already exist in the database. And even if there is no number in it, it says "this number exist"....but it's only when I work with a couple of forms. That variable is declared as public.

    It's hard to explain ! But I hope you understand it....

    So, I think that the problem is that he holds the variable and thinks that it is filled in the textbox.

  8. #8
    Hyperactive Member gmatteson's Avatar
    Join Date
    Feb 2002
    Location
    Rhode Island, USA
    Posts
    293
    setting the variable = nothing destroys it. clears it from memory

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