Just like any other goal, becoming a millionaire by 40, or any age for that matter, requires planning and then doing.
*Think about how much money you need to save each week or month to reach your goal, based on your current age and target age. Write that number down and keep it at the front of your mind at all times. It has to be a realistic number, of course, although it might not be achievable at this moment. For now, focus on that amount rather than the million. It is easier to digest and quicker to reach. Don't forget to write it all down. For most of us there is something powerful about writing things down. Otherwise you either forget a plan ever existed or lose track and take detours that hinder the process.
*Focus on saving the money you get instead of daydreaming how to spend it. Live below your means. Nobody got rich by blowing their money on expensive cars and material stuff. Bargain shop, use coupons, and dare I say... do without! Spend some time differentiating between your wants and needs. When you get extra money, make a plan to save half of it. If you get a raise at work, save half out of every check. Same for bonuses or any other money that comes your way.
In addition to saving that money, earn more of it! Hustle a bit. There are plenty of opportunities for supplemental income. Even if it is only a small amount, it adds up. If you can find a home based business or something that you love, all the better. It might become your primary source of income!
*Be wary of credit cards. I heard a good saying once, "If you eat it or wear it, don't charge it." Ideally if you cannot have it paid off within 3 months you should try to avoid it, as well. Over time the interest you pay will peck away at what you have worked so hard to save, and your future income will be tied up paying off cards.
*Put your money to work for you. Invest! It can be scary but perhaps the biggest hurdle is realizing that you do not need a lot of money to get started. Mark Skousen's Thirty Days to Financial Independence Plan is a super place to start because it presents finances in a very simple and non intimidating way. By the end of the book you will have made your first investment. Just about anyone can do it. And if you can afford it, seek the assistance of a financial planner.