Don’t get me wrong. Nikon 17-55 is probably the best DX lens ever built, and will probably stay the best because DX market has gone amateur. It is way better then 18-105, and anything else for that matter. It was designed for D2H and it is perfect match for it. It sits great on D300 too. If you can afford it you will get the most out of your D40 with it for sure!
On the other hand to put 5 times more expensive and heavier glass on D40 body would be a little strange, not to mention uncomfortable.
My point was that D90 is way better camera then D40, and you could get D90 and 18-105 and 70-300 aside for the price of this glass alone, and get better usability and results overall. 17-55 is currently also very hard to sell second hand, so I am really not sure it is a good buy, especially for D40.