Other topics about Saving/Recalling a Measurement Result
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 transfer files.
Private Sub fromAna_toPC_Click()
'*** This sequence is a sample code in which the file is transferred
'*** from the Ana to the external controller.
Dim hFile As Long
Dim isOpen As Boolean
Dim ioMgr As VisaComLib.ResourceManager
Set ioMgr = New VisaComLib.ResourceManager
Dim Ana As VisaComLib.FormattedIO488
Set Ana = New VisaComLib.FormattedIO488
Set Ana.IO = ioMgr.Open("GPIB0::17::INSTR")
Ana.IO.Timeout = 10000
Dim byteData() As Byte
Dim Ana_File As String
Dim PC_File As String
Ana_File = """" & Trim(TextBox2.Text) & """"
PC_File = Trim(TextBox1.Text)
Ana.WriteString ":MMEM:TRAN? " & Ana_File
byteData = Ana.ReadIEEEBlock(BinaryType_UI1)
hFile = FreeFile()
Open PC_File For Binary Access Write Shared As hFile
isOpen = True
Put #hFile, , byteData
If isOpen Then Close #hFile
Ana.IO.Close
End Sub
Private Sub fromPC_toAna_Click()
'*** This sequence is a sample code in which the file is transferred
'*** from the external controller to the Ana.
Dim hFile As Long
Dim isOpen As Boolean
Dim ioMgr As VisaComLib.ResourceManager
Set ioMgr = New VisaComLib.ResourceManager
Dim Ana As VisaComLib.FormattedIO488
Set Ana = New VisaComLib.FormattedIO488
Set Ana.IO = ioMgr.Open("GPIB0::17::INSTR")
Ana.IO.Timeout = 10000
Dim byteData() As Byte
Dim strBuf As String
Dim fileSize As Long
Dim Ana_File As String
Dim PC_File As String
Ana_File = """" & Trim(TextBox2.Text) & """"
PC_File = Trim(TextBox1.Text)
fileSize = FileLen(PC_File)
ReDim byteData(fileSize - 1)
hFile = FreeFile()
Open PC_File For Binary Access Read Shared As hFile
isOpen = True
Get #hFile, , byteData
If isOpen Then Close #hFile
strBuf = ":MMEM:TRAN " & Ana_File & ","
Ana.WriteIEEEBlock strBuf, byteData, True
Ana.IO.Close
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = "C:\temp\temp.png"
TextBox2.Text = "D:\temp.png"
End Sub
Private Sub EndBtn_Click()
End
End Sub