A function is a module that returns a value back to the part of the program that called it. A function is a group of statements that perform a specific task. When you execute a function, you call it. To call a function in VB you would use something like “Function generateRandom(pingCounter As Integer) As Integer” to start the function. You would then insert the rest of the code that you need and then end the function with the “End Function” command.
To call an external program I found this information and code (at http://en.wikibooks.org/wiki/Visual_Basic/External_Processes):
The simplest way of running an external program is to do something like this:
Shell "cmd /c dir %temp%"
Shell is a built in Visual Basic function that executes a command line and returns a handle to that process. Shell takes an optional argument that controls the window style of the new process (maximized, normal, hidden, etc.).
A couple of other codes found at http://www.canaimasoft.com/f90vb/onlinemanuals/usermanual/TH_45.htm:
To declare a DLL procedure, you add a Declare statement to the declarations section of the code window. If the procedure returns a value, write the declare as a function:
Declare Function publicname Lib "libname" [Alias "alias"] [([[ByVal] variable [As type] [,[ByVal] variable [As type]]...])] As Type
If a procedure does not return a value, write the declare as a Sub:
Declare Sub publicname Lib "libname" [Alias "alias"] [([[ByVal] variable [As type] [,[ByVal] variable [As type]]...])]