If you are trying to stay within code for your city or town, then you need to install a four-wire cable, not a three-wire cable. The four wires are: two hot wires (black and red) one neutral (white) and one ground (green). For a forty amp circuit, you should be using #8 wire. This is a heavy cable or, if you are pulling separate wires, these will be heavy wires and will require a 3/4 inch conduit. If you are installing conduit, keep in mind that you should have no more than 360 degrees of bends between pull points and you should have a helper feed the wire as you pull it through to make sure it enters smoothly, without damaging the insulation.
Your drier may have a three or four wire configuration. As long as you are installing a new four-wire circuit, then you might as well install a four-wire outlet rated for 40 amps. You will also need a four-wire cable with plug to attach your drier to the outlet.
The difference between a three-wire and a four-wire circuit is that the ground is run separately from the neutral wire. Thus when you install your new cable to the drier, remove the tab that connects the white wire to the metal cabinet (ground); attach the green wire to where the tab was connected and then install red, black, and white exactly as they were before.
Viola! You now have 40 amp service to your drier.