That's an easy enough one, I can get that for you; same style as how Lord Stark explained it.
1. Create a common event, name it whatever you would like. For easy reference, I called it code input.
2. Create a new command -> Input Number. Select and name the variable you want the value stored in. I named it the same as the event. Specify 4 digits.
3. Create a new command underneath that; Conditional Branch. The option you'll want is under tab 1, second radio button choice. Select your variable, and select the conditions you would like. Most people that need this type of thing, use it to check if the user has figured out a puzzle, or something of the sort. For ease of example, I put in if "variable 001:code input is equal to 1234"; you can 'set handling when conditions do not apply' if you would like, such as if you want to display an error message if the code is wrong.
4. This depends on what you want to activate when the code is correct, but the easiest way is to create a new command in the conditional branch, under the part for when the conditions are true. Simple create a new "control switches" command, and set it to turn a switch of your choice ON.
4a. Optional: If you have set an 'else' option, specify whatever you would like for it to say, usually in a "Text" command, but there are many other options.
5. Whenever you need to use this code, call it from within an event on the map.
NOTE: You do NOT have to create this as a common event; you can create it as a one time map event as well. Making it as a common event allows you to call it whenever you want, and with some minor modifications to the code used, you can make it a dynamic system, rather than a static one that only compares against one set variable value.
EDIT: I created a quick demo for you as well, with a few extra touches to it. Should be pretty self explanatory.
https://dl.dropboxusercontent.com/u/25886192/Project1.exe