Agilent Technologies E3632A Network Card User Manual


 
Chapter 6 Application Programs
Excel 5.0 Example for Windows 3.1 and GPIB
138
...continued
If InStr(SCPICmd, "?") Then 'If a query read the response string
errorStatus = viRead(vi, ByVal readbuf, 512, actual)
ReturnString = readbuf
'Strip out any nul's from the response string.
crlfpos = InStr(ReturnString, Chr$(0))
If crlfpos Then
ReturnString = Left(ReturnString, crlfpos - 1)
End If
SendSCPI = ReturnString 'return the remaining string
End If ' end of query to instrument for a response
Exit Function
VIerrorHandler:
'Display the error message in the txtResponse TextBox
MsgBox " I/O Error: " & Error$()
'Close the device session
errorStatus = viClose(vi)
Exit Function
End Function
Sub OpenPort()
Dim VISAaddr As String
'****************************
'Change the GPIB address here
'****************************
VISAaddr = "5"
errorStatus = viOpenDefaultRM(videfaultRM) 'open the visa session
'Open communication to instrument
errorStatus = viOpen(videfaultRM, "GPIB0::" & VISAaddr & "::INSTR",0, 1000, vi)
If errorStatus < VI_SUCCESS Then ' on error give message
Cells(1, 1) = "Unable to Open port"
End If
End Sub
Sub ClosePort()
errorStatus = viClose(vi)
'close the session
errorStatus = viClose(videfaultRM)
End Sub
End of Program