Chapter 3 Programming Demos RIGOL
DSA800E Programming Guide 3-15
'Open instrument failed
If (status < VI_SUCCESS) Then
MsgBox " Failed to open the instrument! "
Exit Function
End If
' Read from the instrument
stasus = viRead(sesn, strTemp0, 256, rSize)
' Read failed
If (status < VI_SUCCESS) Then
MsgBox " Failed to read from the instrument! "
Exit Function
End If
'Close the system
status = viClose(sesn)
status = viClose(dfltRM)
' Remove the space at the end of the string
strTemp1 = Left(strTemp0, rSize)
InstrRead = strTemp1
End Function
5. Add the control event codes.
1) Connect to the instrument
' Connect to the instrument
Private Sub CmdConnect_Click()
Const MAX_CNT = 200
Dim status As Long
Dim dfltRM As Long
Dim sesn As Long
Dim fList As Long
Dim buffer As String * MAX_CNT, Desc As String * 256
Dim nList As Long, retCount As Long
Dim rsrcName(19) As String * VI_FIND_BUFLEN, instrDesc As String * VI_FIND_BUFLEN
Dim i, j As Long
Dim strRet As String
Dim bFindDSA As Boolean
' Initialize the system
status = viOpenDefaultRM(dfltRM)
' Initialize failed
If (status < VI_SUCCESS) Then
MsgBox " No VISA resource was opened !"
Exit Sub
End If
' Find instrument resource
Call viFindRsrc(dfltRM, "USB?*INSTR", fList, nList, rsrcName(0))
' Get the list of the instrument(resource)
strRet = ""
bFindDSA = False
For i = 0 To nList - 1
' Get the instrument name
InstrWrite rsrcName(i), "*IDN?"
Sleep 200
strRet = InstrRead(rsrcName(i))