1
VB and the development of wizards / Using the COM API in VB .NET
« on: January 14, 2010, 12:48:01 PM »
I'm trying to use VB .NET to control Mach, and I'm having problems getting things set up. I searched the forums for help, and the only useful topic I found (http://www.machsupport.com/forum/index.php/topic,8429.msg54415/topicseen.html#msg54415) mentions adding Mach3 as a component to your project, then gives the following code snipit:
Public Class Form1
Dim mach As Mach4.IMach4
mach = GetObject(, "Mach4.Document")
Dim scriptObject As Mach4.IMyScriptObject
scriptObject = mach.GetScriptDispatch()
scriptObject.LoadFile("d:\Mach3\GCode\roadrunner.tap")
End Class
I added the Mach3 component by selecting Project->Add Existing Item (BTW, I'm using VB 2008 Express). Then I selected the "Mach3.exe". After that I saw a Mach4 namespace in my component browser window with a class named "CMach4Doc". I then copied the code into the form procedure and tried to run the program.
The compiler complains that "Mach4.IMach4" is not defined. Since the class name is CMach4Doc, I also tried "Dim mach As Mach4.CMach4Doc" with the same results.
I'm sure I'm missing something obvious, I just don't know what.
Tony
Public Class Form1
Dim mach As Mach4.IMach4
mach = GetObject(, "Mach4.Document")
Dim scriptObject As Mach4.IMyScriptObject
scriptObject = mach.GetScriptDispatch()
scriptObject.LoadFile("d:\Mach3\GCode\roadrunner.tap")
End Class
I added the Mach3 component by selecting Project->Add Existing Item (BTW, I'm using VB 2008 Express). Then I selected the "Mach3.exe". After that I saw a Mach4 namespace in my component browser window with a class named "CMach4Doc". I then copied the code into the form procedure and tried to run the program.
The compiler complains that "Mach4.IMach4" is not defined. Since the class name is CMach4Doc, I also tried "Dim mach As Mach4.CMach4Doc" with the same results.
I'm sure I'm missing something obvious, I just don't know what.
Tony