Hi,
while executing a infopath form, always rules associated to the control will trriger first then the functions will be executed.
To submit infopath forn using vbscript . try the following code
XDocument.DataAdapters("Data Connection Name").Submit
Regards,
Naveen.