How to Replace the Ballast in a Fluorescent Lighting Fixture
To safely replace the ballast in your fluorescent light, turn off the lamp, remove it, and check the voltage of the feed wires with a voltmeter. Then, use a nut driver to unscrew the nut holding the ballast in place and install the replacement ballast. Insert the red, blue, black and white wires in their corresponding holes, screw the nut back in place and replace the lamp.
Before you go to the trouble of replacing the ballast, you should determine if a bad ballast is indeed the likely cause of the problem. First, replace the tubes with new tubes or with tubes that you know are good. Usually, if the lamps have turned black at one or both ends, they are bad, but the only way to know for sure is to replace them with good ones. Note, however, that fluorescent lamps generally burn out gradually over time, not suddenly. If all of the tubes in a fixture stop working abruptly at the same time, it's likely that the problem is not the tubes.  If replacing the tubes does not fix the problem and if the light fixture has one or more "starters" (found only in older fixtures), replace the starters. There will be one starter per lamp (tube). The starter is a small cylindrical part (3/4-inch (20 mm) diameter x 1 1/4-inch (30 mm) long) that is twisted into a separate socket, usually located near the end of the fixture or behind a lamp. Starters are very inexpensive (about $2 each) and easy to replace. It is difficult to determine if starters are functional merely by inspecting them visually. Swap with a new or known "good" starter to check. If changing the tubes and starters does not correct the problem, the most likely culprit is the ballast. Remove the lamps and place them in a safe location.  Turn the light off at the switch, as well as at the circuit breaker. (If you are not sure which breaker operates the light, shut off the whole house breaker to be safe.) Turn the metal tabs near the center of the fixture perpendicular to its length. It will fall away from the fixture. Pull it toward you and store it in a convenient place. Do the same with the other side. Before you cut any wires, it is recommended that you check both the hot and neutral feed wires for voltage with respect to ground. (And see the alternative to cutting in step 11 before doing any cutting.) The voltage can be checked with a simple voltmeter or voltage sensor. Locate the ballast and follow the wires until you find the wire nuts (caps) that connect wires of the same color (red to red, etc.). If there are no wire nuts, you will have to cut the wires about 12 inches (30 cm) (300 mm) from the center of the fixture on each side. Complete this until all wires are cut or all wire nuts are removed. Unscrew the nut holding the ballast to the fixture while holding it in place with your other hand. This is best done with a nut driver or socket wrench. Remove the ballast by lowering the side held by the nut, and sliding it in that direction. Take the ballast with you to your local home center or hardware store and purchase a like replacement. Note the number of tubes in your fixture and their wattage, length, type (T8, T12, T5, etc.). Note also there may be two ballasts in a four-tube fixture, each ballast running two of the tubes. Install the replacement ballast by reversing the instructions in step 5. Be sure the red and blue wire face the end with red and blue wires, and the black and white wires face the other end. If you opt for the cutting method, cut the wires so they overlap the fixture wires by about 6 inches (15 cm) (150 mm).  Strip about 1/2" (12 mm) of insulation from the ends of all 8 of the wires.  Use a wire nut to connect the blue wire to the blue wire, the red to the red, the white to the white, and the black to the black. As a quick and easy alternative to cutting and wiring, simply rotate and pull the wires out of the lamp connectors. A little back and forth rotation (in the manner of a screwdriver) suffices, but is necessary otherwise the wires won't come out. Make a note of the wire colors when you pull them out. To connect the new ballast, simply push the wire into the hole from which you pulled the old wire out and give the wire a tug to make sure it's seated firmly, the same method as used at the factory. Reverse step 3. Make sure the tabs are in the holes at the end of the fixture. Replace the new lamps.  Turn on the light.  
Before you go to the trouble of replacing the ballast, you should determine if a bad ballast is indeed the likely cause of the problem. Remove the lamps and place them in a safe location. Turn the light off at the switch, as well as at the circuit breaker. Before you cut any wires, it is recommended that you check both the hot and neutral feed wires for voltage with respect to ground. Unscrew the nut holding the ballast to the fixture while holding it in place with your other hand. Take the ballast with you to your local home center or hardware store and purchase a like replacement. Install the replacement ballast by reversing the instructions in step 5. If you opt for the cutting method, cut the wires so they overlap the fixture wires by about 6 inches (15 cm) (150 mm). Strip about 1/2" (12 mm) of insulation from the ends of all 8 of the wires. Use a wire nut to connect the blue wire to the blue wire, the red to the red, the white to the white, and the black to the black. Reverse step 3. Replace the new lamps. Turn on the light. 