Creating Functions/Subroutines inside Invoke Code

you should check this Invoke code activity VB.Net example