Can I become a pilot at 40?
As a general rule I like to think it's never to late. In your case, it's too late for the Airforce, but it's not too late for the regionals!
You have plenty of time. Someone in their 50's could still do it!!
You should really ask yourself some hard questions.
Do you really want to be treated like a piece of equipment aka "crap"? My drill instructors showed more love than regional schedulers.
Do you really want to be gone from your family 19 days every month? 17 if you are lucky.
Do you want to pay out almost 100k to get trained for a job that pays less than a McDonald's manager? With bonuses a McDonald's starting manager can earn near 40k. A first year Mesa F/O earns less than 21k, even if hired as a Captain you won't beat the Mc Donalds Manager.
Do you have enough saved to maintain a decent quality of life for several years? You won't make enough to live at the poverty level for several years.
Don't believe this rumor of pilot shortage you hear. It's a mythical creature that was supposed to come several times in the 80's, 90's, 00's.. and it never did.
Any airline that treats pilots well, and pays a decent wage has a pile of qualified resumes that far outpaces their demand, and always will.
So if you can answer all these in the affirmative.. go for it!
If, many years later you do make it to an airline like Virgin America, and they don't go out of business... once you get some seniority there, life can be good again!!