When you say "write a small program in Visual Basic" do you mean Mach's Visual Basic scripting, or a standalone Visual Basic application? VB6 or VB.Net?
For a standalone program, you can use the Mach COM API. Write your program to do the conversion, save the data to a file, then your program can use the COM API to tell Mach to load the file, and execute it. The COM API is quite powerful. Just add a Mach3 COM object reference to your project and browse the methods exposed by the object. I think there are examples around, but not sure where. There are some reference counting bugs though with the API. It can cause Mach to crash when you exit your application.
If you are writing a script, I think you can use the OpenTeachFile/CloseTeachFile/LoadTeachFile methods. Look at some of the wizards for ideas. You can load a wizard, then use the "edit button script" menu option to view the code of non-protected wizards.
Frank