Keysight B2980 Programming Guide, Edition 1
2- 5
Programming Examples
Preparations
Table 2-1
Example Template Program Code
Module Module1
Sub Main() ’1
Dim rm As Ivi.Visa.Interop.ResourceManager
Dim ioObj As Ivi.Visa.Interop.FormattedIO488
Dim ifAddress As String = "23"
Dim filename As String = ""
Dim filedata As String = "Result: "
Dim s As String = ""
Try ’9
rm = New Ivi.Visa.Interop.ResourceManager
ioObj = New Ivi.Visa.Interop.FormattedIO488
Try
ioObj.IO = rm.Open("GPIB0::" + ifA "::INSTR")
ioObj.IO.Timeout = 60000
ioObj.IO.TerminationCharacter = 10
ioObj.IO.TerminationCharacterEnabled = True
Catch ex As Exception
Console.WriteLine("An error occurred: " + ex.Message)
End Try
B2900control(ioObj, s, filename) ’21
Console.Write(fi s)
MsgBox("Click OK to close the console window.", vbOKOnly, "")
FileOpen(1, filename, OpenMode.Output, OpenAccess.Write,
OpenShare.LockReadWrite) ’25
Print(1, fi s)
FileClose(1)
ioObj.IO.Close() ’29
System.Runtime.InteropServices.Marshal.ReleaseComObject(ioObj)
System.Runtime.InteropServices.Marshal.ReleaseComObject(rm)
Catch ex As Exception
Console.WriteLine("An error occurred: " + ex.Message)
End Try
End Sub
Sub B2900control(ByVal ioObj As Ivi.Visa.Interop.FormattedIO488, ByRef s As
String, ByRef filename As String) ’37
filename = "../../../execution result/resultdata1.txt"
End Sub
End Module
Line
Description
1 to 8
Beginning of the Main subprogram. And defines the variables used in this program.
9 to 20
Establishes the connection with the B2980 specified by the GPIB address ifAddress=23 on
the interface GPIB0.