- From the Microsoft Visual Basic project window, choose
Tools :: Project Properties - Choose the Protection tab
- Check the box to "Lock project for viewing," set a password, and hit OK.
Once the project is closed (or another/new project is opened) and reloaded, viewing or editing any code will be restricted until the password is entered. Full access is granted for the remainder of the time that the project is loaded.
The code is even restricted during an error.