Is it true that wasps don't sting if struck by hand while flying? I know of one person who claims to have done this at least 20 times and has never been stung. And out of curiosity (not that I'd want to kill them), what about bees?
I think what your friend advised is incorrect, or they are very lucky. According to "Bee and Wasp Stings" from the University of California Davis, they specifically state:
Unless someone accidentally collides quite hard with or swats at a bee or wasp, it is not likely to sting.
Also, if you swat at some species, they are likely to become agitated, making the situation potentially far worse.
I can confirm that I have often enough slapped a wasp or bee in flight without being stung. The reason is probably pure chance.
It is kind of like asking if a human can bite when slapped. If I come up to you and slap you, fast and hard, you will probably not be able to bite my hand because of surprise and the blinding speed with which I hit you. If, however, you happen to be talking to me and have your mouth open at the time, you might be able to pull off a quick bite.
In a similar vein, if I happen to swap a wasp (no anagram intended) and hit it on the sting, I will probably be stung. If I hit it on the side and move fast enough, I doubt it will have the time to reorient itself and sting me before my hand is gone.
I have many experiences with bees. I avoid swatting bees/wasps, since if you do not agitate them, they fly away and are not interested in humans or exploring human skin. (They are also important pollinators.) If you slap them very hard, you can instantly kill a bee, especially if it collides perpendicularly with a wall afterwards. If you swat it a bit less vigorously, like I did yesterday, my finger got slightly red and itchy; I was partially stung and/or the venom was transferred to my finger, which is normally stored in a cuticular sac in the abdomen of the bee and is quite potent, given its small volume.
Don't hurt bees and they can't hurt you. If you agitate bees, they will defend themselves. Any insect of sufficient size and mass can be hurt with a blow of sufficient energy. Tiny fruit flies are too small for a slap, large moths, bees, dragonflies can be slapped down when in flight.