Generally, you can get an after-market 9mm barrel for most .40s, but not the other way around.
Bar-Sto and other providers of "conversion" barrels adjust the 9mm conversion barrel to be the same diameter as the .40 barrel, and make other changes so that the existing extractor will work. They do this for SIGs and Glocks.
Most of these barrel makers won't consider selling a barrel that will shoot .40 in a 9mm slide -- first because they can't make them fit. And it's a very unusual stock barrel that will work in both a 9mm and .40 slide.
(One exception is the Witness line. Some of the older models had 9mm and .40 barrels of the same diameter, and their newer models offer interchangeable slides.)
Sometimes, too, the frames of the .40 models are beefed up a little to handle the larger round. (The Browning High Power frames for .40s are not the same as the 9mm frames, for example. Some of the SIG .40s are slightly larger than the same model in 9mm.)