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
Printable View
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
I dont think you can in VB. All i can think of is setting the variable = nothing...but that wont get rid or it.
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
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.Quote:
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 ?
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
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
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.
setting the variable = nothing destroys it. clears it from memory