After going to settings > options > advanced options > sim card, you type MEPD (or mepd). Then you press alt key while also typing MEPE (or mepe). Then you will see "Enter Network MEP Code" and you type unlock code and then press the wheel.
After 10 incorrect unlock codes have been entered, the device will permanently lock to that carrier and cannot be unlocked EXCEPT by RIM, and by shipping the device to them.
If the device is unlocked (Network: Disabled) and you can not put in a working, valid SIM for your carrier, then you either have a hardware problem, or a device that was reported to the carrier as lost or stolen.