Other topics about Controlling Peripherals
The following figure shows the flow of controlling the instrument with VISA-COM.
In Visual Basic menu bar, select Tools > Reference
Check "VISA COM 3.0 Type Library"
'*** The variables of the resource manager and the instrument I/O are declared
Dim ioMgr As VisaComLib.ResourceManager
Dim Equip As VisaComLib.FormattedIO488
Sub Main()
' This sample program allows you to control the external instrument from the built-in VBA.
' 1. Connect USB-GPIB interface between the external instrument and the ENA USB port.
' (If you change the VISA address, you can use USB and LAN connection.)
' 2. Set the GPIB Address at 17
' 3. In Visual Basic menu bar, select Tools > Reference
' 4. Check "VISA COM 3.0 Type Library".
'
'*** The memory area of the resource manager and the instrument I/O are acquired
Set ioMgr = New VisaComLib.ResourceManager
Set Equip = New VisaComLib.FormattedIO488
'*** Variable declaration
' Dim status As String 'VISA function status return code
Dim Prod As String * 100 'String to receive the result
'*** Open the instrument
Set Equip.IO = ioMgr.Open("GPIB0::17::INSTR") ' Change the VISA address when you use USB or LAN.
Equip.IO.timeout = 100000 ' TimeOut time should be greater than the measurement time.
'*** Asks for the instrument's product information.
Equip.WriteString "*IDN?", True
'*** Reads the result.
Prod = Equip.ReadString
'*** Displays the result.
MsgBox Prod
'*** Closes the resource manager session (which closes everything)
Equip.IO.Close
End Sub