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 = ""
bFindDG = False
For i = 0 To nList - 1
' Get the instrument name
InstrWrite rsrcName(i), "*IDN?"
Sleep 200
strRet = InstrRead(rsrcName(i))
' Continue to switch the resource until find a DG instrument
strRet = UCase(strRet)
j = InStr(strRet, "DG")
If (j >= 0) Then
bFindDG = True
Exit For
End If
Call viFindNext(fList + i - 1, rsrcName(i))
Next i
'Dispaly
If (bFindDG = True) Then
TxtInsAddr.Text = rsrcName(i)
Else
TxtInsAddr.Text = ""
End If
End Sub
2) Write Operation
'Write the command to the instrument
Private Sub CmdWrite_Click()
If (TxtInsAddr.Text = "") Then
MsgBox ("Please write the instrument address!")
End If
InstrWrite TxtInsAddr.Text, TxtCommand.Text
End Sub
3) Read Operation
'Read the return value from the instrument
Private Sub CmdRead_Click()
Dim strTemp As String
strTemp = InstrRead(TxtInsAddr.Text)
TxtReturn.Text = strTemp
End Sub