Section 2: General operation
Models 707B and 708B Switching Matrix Reference Manual
2-68
707B-901-01 Rev. A / August 2010
VISA-COM sample code
This example gets the instrument identification string using VISA-COM in C#.
The first thing to do is add a reference to the VISA-COM interop DLL, which is usually located at
C:\Program Files\IVI Foundation\VISA\VisaCom\Primary Interop Assemblies\Ivi.Visa.Interop.dll.
using Ivi.Visa.Interop;
namespace WindowsApplication1
{
public class IdnSample: System.Windows.Forms.Form
{
private Ivi.Visa.Interop.FormattedIO488 ioDmm;
//
}
}
private void IdnSample_Load(object sender, System.EventArgs e)
{
ioDmm = new FormattedIO488Class();
SetAccessForClosed();
}
private void btnInitIO_Click(object sender, System.EventArgs e)
{
try
{
ResourceManager grm = new ResourceManager();
ioDmm.IO = (IMessage)grm.Open("GPIB::16::INSTR",
AccessMode.NO_LOCK, 2000, "");
ioDmm.IO.TerminationCharacterEnabled = true;
}
catch (SystemException ex)
{
MessageBox.Show("Open failed on " + this.txtAddress.Text + " " +
ex. " " + ex.Message, "IdnSample", MessageBoxButtons.OK,
MessageBoxIcon.Error);
ioDmm.IO = null;
}
}