|
-
Aug 13th, 2001, 04:50 PM
#1
Thread Starter
Junior Member
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
-
Aug 13th, 2001, 05:12 PM
#2
Frenzied Member
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.
-
Aug 13th, 2001, 05:15 PM
#3
PowerPoster
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
-
Aug 13th, 2001, 05:45 PM
#4
Member
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.
-
Aug 14th, 2001, 01:03 AM
#5
Thread Starter
Junior Member
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
-
Aug 14th, 2001, 04:12 AM
#6
PowerPoster
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
-
Aug 14th, 2001, 08:16 AM
#7
Thread Starter
Junior Member
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.
-
Oct 2nd, 2002, 10:41 AM
#8
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|