Programming Examples 12
Agilent InfiniiVision 5000 Series Oscilloscopes Programmer's Guide 765
private void OpenIo()
{
m_ResourceManager = new ResourceManagerClass();
m_IoObject = new FormattedIO488Class();
// Open the default VISA COM IO object.
try
{
m_IoObject.IO =
(IMessage)m_ResourceManager.Open(m_strVisaAddress,
AccessMode.NO_LOCK, 0, "");
}
catch (Exception e)
{
Console.WriteLine("An error occurred: {0}", e.Message);
}
}
public void SetTimeoutSeconds(int nSeconds)
{
m_IoObject.IO.Timeout = nSeconds * 1000;
}
public void Close()
{
try
{
m_IoObject.IO.Close();
}
catch {}
try
{
Marshal.ReleaseComObject(m_IoObject);
}
catch {}
try
{
Marshal.ReleaseComObject(m_ResourceManager);
}
catch {}
}
}
}
VISA COM Example in Visual Basic .NET
To compile and run this example in Microsoft Visual Studio 2005:
1 Open Visual Studio.
2 Create a new Visual Basic, Windows, Console Application project.
3 Cut- and- paste the code that follows into the C# source file.