Remove the screw from the knob of the shower valve. Pull the knob directly away from the wall to remove it. These are often hard to remove. If it is stuck, a gear puller will help. If you do not have access to a gear puller, place a piece of 1-inch thick lumber against the shower wall or tile to protect it, insert the claw end of a hammer behind the knob, and pry it toward you.
Use a wrench to remove the threaded metal sleeve that is around the shower valve. Cut away any caulking that is in the way so you can get to the shower valve.
Use a wrench to unscrew the shower valve and pull it out. Take the old shower valve with you for reference and go to a home improvement or plumbing supply store to buy a replacement valve.
Screw the new valve into place and tighten with a wrench. Check the alignment so that the shower position and tub postion of the valve are how you want them. Reattach the metal sleeve and tighten with the wrench.
Re-apply caulking to seal off any gaps and prevent water from leaking inside the shower walls. Screw back on the shower knob.