[QUOTE=diplomacy;867020]He went to the store
for buyingto buy milk and bread (Infinitive of purpose which answers the question: what did he go to the shop for?) .
He got into trouble with his teacher for being late. (FOR+ING explains the cause of his getting into trouble. As a result it refers to a prior event or condition, i.e. being late, to the main event, i.e. got into trouble)
Hope it's clear.
- For Teachers