Programming
283
Analyzer.IO.Close
End Sub
Writing Data
Sub Write_Click()
Dim WriteData() As Double
Dim Poin As Integer, DataType As String, TraceNo As String
'*** The variables of the resource manager and the instrument I/O are declared.
Dim ioMgr As VisaComLib.ResourceManager
Dim Analyzer As VisaComLib.FormattedIO488
'*** The memory area of the resource manager and the instrument I/O are acquired.
Set ioMgr = New VisaComLib.ResourceManager
Set Analyzer = New VisaComLib.FormattedIO488
'*** Open the instrument.
Set Analyzer.IO = ioMgr.Open("GPIB0::17::INSTR")
Analyzer.IO.Timeout = 10000
'*** Abort sweeping.
Analyzer.WriteString ":INIT1:CONT OFF", True
Analyzer.WriteString ":ABOR", True
'*** Select trace
TraceNo = Cells(3, 2)
Analyzer.WriteString ":CALC1:PAR" & TraceNo & ":SEL", True
'*** Get number of point.
Analyzer.WriteString ":SENS1:SWE:POIN?", True
Poin = Analyzer.ReadNumber
ReDim WriteData(Poin * 2 - 1) As Double
'*** Set data for array variable, and send data for the Analyzer
For i = 1 To Poin
WriteData(i * 2 - 2) = ActiveSheet.Cells(i + 10, 2).Value