Private Sub vbMain()
Const MAX_CNT = 200
Dim stat Dim dfltRM Dim sesn Dim retCount Dim buffer | As ViStatus As ViSession As ViSession As Long As String * MAX_CNT |
Rem Begin by initializing the system
stat = viOpenDefaultRM(dfltRM)
If (stat < VI_SUCCESS) Then
Rem Error initializing VISA...exiting
Exit Sub
End If
Rem Open communication with GPIB Device at Primary Addr 1
Rem NOTE: For simplicity, we will not show error checking
stat = viOpen(dfltRM, "GPIB0::1::INSTR", VI_NULL, VI_NULL, sesn)
Rem Set the timeout for message-based communication
stat = viSetAttribute(sesn, VI_ATTR_TMO_VALUE, 5000)
Rem Ask the device for identification
stat = viWrite(sesn, "*IDN?", 5, retCount)
stat = viRead(sesn, buffer, MAX_CNT, retCount)
Rem Your code should process the data
Rem Close down the system
stat = viClose (sesn)
stat = viClose (dfltRM)
End Sub |