A shower's diverter valve regulates the flow of water in the faucet assembly, directing it either through the tub's spout or the shower head. Some showers have a diverter valve in the bathtub spout, requiring you to replace the entire spout. Other shower faucets have the diverter valve as a third water control handle that sits between the hot and cold water handles, meaning you remove the old diverter valve and install a new one, similar to when you repair a faucet leak.
Examine the bottom of the tub's spout for a set screw holding the spout in place. The screw may be in a small hole or in a notched-out area at the back of the spout. Use an Allen wrench to remove the screw, being careful to not drop it down the drain.
Slide the tub's spout directly off the water pipe, twisting it back and forth if the spout sticks at all. If the spout does not have a set screw in the bottom, wrap a piece of cloth around the spout, then clamp a pipe wrench to the spout and turn the spout counterclockwise until the spout comes off the water pipe.
Install a replacement spout, with the same location for the diverter, onto the water pipe the same way you removed the old spout. If the opening in the new spout is too big for the water pipe, screw in the plastic adaptor piece into the opening in the spout before installing it onto the water pipe.
Turn off the water in the house by closing the main water valve. Turn on the shower's faucet all the way to eliminate any pressure left over in the water pipes.
Pry off the small cap piece in the middle of the diverter's control knob. Use a Phillips screwdriver to remove the screw that sits underneath the cap, then pull the handle off the faucet.
Unscrew any adaptor pieces or nuts attached to the valve stem, using a pair of pliers. Pull out any metal pins or clips, using needle-nose pliers.
Slide the handle back over the stem valve, then turn the handle counterclockwise until the valve comes out of the water pipe. Screw a new valve into the pipe, turning it clockwise with the handle until it sits firmly in place.
Replace the other parts of the faucet in the reverse order you removed them, then open the house's main water valve.