Yes, you can avoid the runs when you travel.
Nothing is less appealing than coming down with a dose of diarrhoea while travelling in a foreign land. I suspect fear of getting a stomach bug is a big reason why many travellers are reluctant to visit Third World countries and, if they do go, why they avoid local food.
But, in my experience, if you behave sensibly you've got a very good chance of avoiding Delhi Belly, Montezuma's Revenge, the Cairo Two-step or any of their cousins.
Over the years I've travelled in India, China, Southeast Asia, the Middle East, Central and South America and Africa and only once got the runs. That was after three weeks' roughing it in Papua New Guinea - including being eaten alive by bed bugs - and I think represented a gesture of protest by my poor, battered old body rather than an actual stomach bug.
The key to avoiding bugs is prolific use of hand-sanitiser. I got this message years ago while doing a fantastic rail journey from Beijing via Mongolia and Russia to Helsinki, with Perth-based Travel Directors.