As they fly they let out sharp calls which are normally too high-pitched for the human ear to hear. The returning echoes give the bats information about anything that is ahead of them, including the size and shape of an insect and which way it is going.
This system is called echolocation - locating things by their echoes.