Programming 
281 
Other topics about Reading/Writing Measurement Data 
Overview 
The program listed in the below section is written in VISA-COM with Excel 
VBA. It can be executed from the external PC controller. The program 
demonstrates how to read/write data. 
Reading/Writing Data Sample Program in Excel VBA 
Reading Data 
Sub Read_Click() 
 Dim ReadData() As Double, FreqData() 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 of the stimulus data. 
 Analyzer.WriteString ":SENS1:SWE:POIN?", True 
 Poin = Analyzer.ReadNumber 
 ReDim FreqData(Poin - 1) 
 ReDim ReadData(Poin * 2 - 1)