Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cleaning up Unsed Code Entries 2

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
In VB6 I find that if I create a control (say a button) on a form. Then at a later time remove it. The code for the button remains! [3eyes]

What is the best way to ensure all code that is bound to controls that have been removed is purged?

Thanks!
 
Well, seeings how this would only happen with the control's event proceedures (any other code would cause an error if Option Explicit is on, or unless you have a variable with the same name as the removed control) then I guess the best method is experience and habit.

Before removing the control, look in the controls code events window to see if there are any (Bold text), and if so, click on them and remove them.
 
CCLINT, thanks for the reply.

I believe I have Option Explicit on and no vars with the same name. I am at currently removing the code simliar to your suggestion.

1. A control is removed from a form that has event code in it.
2. In the Form's General area code remnants from the removed control are visible.
3. I manually remove the private sub that has no control parent.

I was hoping there would be an automated way to do this. I think VB3 does it for you. :)

Thanks again for your advice!
 
There is a freeware tool for VB from:
which has a 'Review source code' tool amongst a load of other useful gadgets
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Thanks John for putting the mztools package on the site, I downloaded it and used the review source code. Very good, I had to assure myself it was telling me the truth before I deleted numerous lines of unwanted/unused event code, and it was totally correct. Deserve a star for a useful freebie. Thanks
 
Thanks for the suggestion John. It looks to go to be true, maybe we could get some people to test this out, I'm still leary on using it. I do not want to have any of my code to 'disappear'. Rob
 
I've been using it for some time, and have seen no problems yet!
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
And by looking at his website, he does update his versions frequently. Rob
 
I have been using mztools since version 2 and it has never failed me

Shawn
 
I too use mztools and have not experience any problems. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I've now been using this all weekend and it works great! Thanks again! Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top