Programming Examples
40
Keysight InfiniiVision M9241/42/43A PXIe Oscilloscopes SCPI Programmer's Guide
1441
VISA Example in Visual Basic .NET
To compile and run this example in Microsoft Visual Studio 2008:
1
Open Visual Studio.
2
Create a new Visual Basic, Windows, Console Application project.
3
Cut-and-paste the code that follows into the Visual Basic .NET source file.
4
Edit the program to use the VISA address of your oscilloscope.
5
Add Keysight's VISA header file to your project:
a
Right-click the project you wish to modify (not the solution) in the Solution
Explorer window of the Microsoft Visual Studio environment.
b
Choose
Add
and then choose
Add Existing Item...
c
Navigate to the header file, visa32.vb (installed with Keysight IO Libraries
Suite and found in the Program Files (x86)\IVI Foundation\VISA\WinNT\
Include directory), select it, but
do not click the Open button
.
d
Click the down arrow to the right of the
Add
button, and choose
Add as Link
.
You should now see the file underneath your project in the Solution Explorer.
It will have a little arrow icon in its lower left corner, indicating that it is a
link.
e
Right-click the project again and choose
Properties
; then, select
"InfiniiVision.VisaInstrumentApp" as the
Startup object
.
6
Build and run the program.
For more information, see the tutorial on using VISA in Microsoft .NET in the VISA
Help that comes with Keysight IO Libraries Suite 17.
'
' Keysight VISA Example in Visual Basic .NET
' -------------------------------------------------------------------
' This program illustrates a few commonly-used programming
' features of your Keysight oscilloscope.
' -------------------------------------------------------------------
Imports System
Imports System.IO
Imports System.Text
Namespace InfiniiVision
Class VisaInstrumentApp
Private Shared myScope As VisaInstrument
Public Shared Sub Main(ByVal args As String())
Try
myScope = _
New VisaInstrument("TCPIP0::10.112.94.136::hislip9-0.0::INSTR"
)
myScope.SetTimeoutSeconds(10)