Agilent 4155C/4156C VXIplug&play Driver User’s Guide, Edition 4 4-5
Programming Examples for Visual Basic .NET Users
Programming Basics
Table 4-1 Example Template Program Code for Visual Basic .NET
Imports Agilent.TMFramework ’1
Imports Agilent.TMFramework.DataAnalysis
Imports Agilent.TMFramework.DataVisualization
Imports Agilent.TMFramework.InstrumentIO
Imports Agilent.TMFramework.InstrumentDriverInterop
Imports Agilent.TMFramework.InstrumentDriverInterop.Design
Imports Agilent.TMFramework.InstrumentDriverInterop.VxipnpWrappers
Module Module1
Sub Main() ’11
Dim Ag415x As Hp4156b = New Hp4156b("GPIB0::17::INSTR", True, True)
Ag415x.Reset()
Ag415x.TimeOut(60000)
MsgBox("Click OK to start measurement.", vbOKOnly, "")
Console.WriteLine("Measurement in progress. . ." & Chr(10))
perform_meas(Ag415x)
Ag415x.SetSwitch(0, 0)
Ag415x.Close()
MsgBox("Click OK to stop the program.", vbOKOnly, "")
Console.WriteLine("Measurement completed." & Chr(10))
End Sub ’24
Line Description
1 to 7 These lines are necessary to use the Agilent 4155/4156 VXIplug&play driver.
11 to 24 Main subprogram establishes the software connection with the Agilent 4155/4156, resets the
4155/4156, sets the driver I/O time out to 60 seconds, opens a message box to confirm the
start of measurement, and pauses program execution until OK is clicked on the message
box. By clicking OK, the program displays a message on the console window and calls the
perform_meas subprogram that is used to perform measurement.
After the measurement, the program disables all channels, disables the software connection
with the 4155/4156, and opens a message box to confirm the end of the program. Finally, the
program displays a message on the console window by clicking OK on the message box.
12 The above example is for the 4155/4156 on the GPIB address 17. Confirm the GPIB address
of your 4155/4156, and set the address correctly instead of “17”.