Instructions

Table Of Contents
Chapter 3 Programming Examples RIGOL
RSA5000 Programming Guide 3-13
MsgBox " Failed to open the instrument! "
Exit Function
End If
'Read from the instrument
stasus = viRead(sesn, strTemp0, 256, rSize)
'Reading 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 bFindRSA As Boolean
'Initialize the system
status = viOpenDefaultRM(dfltRM)
'Initialization 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 instruments (resources)
strRet = ""
bFindRSA = False
For i = 0 To nList - 1
'Get the instrument name
InstrWrite rsrcName(i), "*IDN?"
Sleep 200
strRet = InstrRead(rsrcName(i))
'Continuing searching for the resource until an RSA instrument is found
strRet = UCase(strRet)