What exactly is the problem you are having? The task is very simple and has been discussed before. If you are using a bar code scanner, just search the forum for that. If you would post the code you've written, someone could look at it and see what the problem is (if in fact you describe the problem).
And in case you haven't seen it before, there are tutorials available.