Typically during a buy-out, the buyer will pay out the bought company's stocks for their current price. So if you owned 1 share of Yahoo stock, and it was priced at 20 dollars, and Microsoft bought Yahoo, Microsoft would pay you 20 dollars, and your stock in Yahoo would then become null and void.
However...
Chances are, if Microsoft buys Yahoo, they would keep Yahoo open, but just own them, so you'd still be able to buy stock in Yahoo, and they'd still run independently, just under the ownership of Microsoft. I mean Microsoft would make so much money by just taking Yahoo's earnings.