devxlogo

Clean and Compact Your Code

Clean and Compact Your Code

The last thing you should do before creating your final EXE is clean your code. This tip explains how to clean the garbage from your project that is sometimes left behind from moving procedures in and out of different project files. Doing so will make your project files smaller and, in some cases, eliminate possible GPFs due to code being left behind by only deleting a pointer to the code. This routine works for forms and module files.Start Visual Basic and load your project. Make sure that all your code windows are closed. Highlight the first file in your project window. Then select Save Text from the File menu. Click on OK to save the file in text format. Highlight the same file in the project window. Click on the View Code button in the project window. Select Load Text from the File menu. Find and highlight the previously saved file (FormName.txt). Click on Replace. Finally, close the code window. Repeat the same steps for each file in the project and then save your project.This procedure will remove the transparent dead code left over from deleting code or moving procedures in and out of different project files. You will be able to see the results in the size of your project files after you run this routine for each file in your project and save your project. This cleaning can also prevent GPFs that are caused sometimes by this transparent dead code. This routine does not remove code that is moved to the general declaration section of a file because you changed a control’s name. It removes old data you thought you deleted, but you actually deleted only a reference pointer to it. The code is still there, but it is transparent in the code windows.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist