Don't take 40 of any pills unless prescribed by a physician,that can seriously injure your liver and possibly kill you.Your liver will be messed up like you've been drinking for 20 years,you will be taken into the hospital if you live and they will stomach pump you and try to dilute it out of you system.Do not do it!
Did you take 40 valiums all at once? And if so, are you still alive to tell about it? That's a lot, dude. Take it easy. Anyway, the answer below may be more accurate than other websites' claims. Most of my research says that benzo's (valium, xanax, klonipin, lorazepam) are out of your system in a few days (4 at most, even with daily or excessive use). But, I had a drug screen two weeks after I'd taken xanax (and it was like maybe 4mg's over the course of two or three days) and I popped positive, though the levels were almost non-existent.
Even just 1 time or occasional use is 2 weeks. Daily use takes 4-6 weeks to clear the system.