HEM Data Support: Helpful Hints
Navigation

A Simple Visual Basic Application To Open And Start A Snap-Master Instrument

1. Install the Snap-Master Programmer’s Toolkit. If you do not have the Programmer’s Toolkit, make sure that SMAPI.DLL file is located in the C:\WINDOWS\SYSTEM directory.
2. Start Snap-Master (Make sure that the DDE Out icon is at the bottom of the Toolbox). Create an instrument containing the A/D Demo connected to a Display. Save the instrument as “c:\sm\defuser\test.ins”.
3. Create a new application using Visual Basic using the File menu, New Project command.
* Add a command button to the form. It will be called “Command1″.
* Double click on the form (not the button). This should open the Form_Load code procedure.
* Click on the down arrow to access the Object declarations, and select the (general) option.
* In the (declarations) procedure, type the following:
Declare Function InstrumentStart Lib “smapi.dll” (ByVal lpszIns As String) As Integer
Declare Function InstrumentOpen Lib “smapi.dll” (ByVal lpszIns As String) As Integer
* Click on the down arrow to access the Object declarations, and select Command1.
* In the Click procedure, type the following code between the Sub Command1_Click () and End Sub lines:
InsName$ = "c:\sm\defuser\test.ins"
A% = InstrumentOpen(InsName$)
A% = InstrumentStart(InsName$)

* Save the project and form as SMTEST using the File menu, Save Project command.
4. Run the application using Visual Basic by pressing the F5 function key.
* The application should open the instrument, and start the Snap-Master instrument.
* If the program does not work, then stop the VB app and run in Step mode using the F8 function key. The value of A% should always be -1. If the value is -2, then there is an error in the DDE conversation.