Choose Project - Add Module.

For defining just define any normal function there and just remember to make it public.

Call the subroutine from any event you wish to.