Other topics about Sample Programs
The sample program demonstrates how to save a file. This program saves selected content on a file with a specified name.
See Saving and Recalling File for this programming.
Example of excel sheet and window form with saving files program
Private Sub File_Save_Click()
' Declare two string variables for file name and file type
Dim File_Name As String
Dim File_Type As String
Dim ioMgr As VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
'*** The memory area of the resource manager and the instrument I/O are acquired.
Set ioMgr = New VisaComLib.ResourceManager
Set Ena = New VisaComLib.FormattedIO488
'*** Open the instrument.
Set Ena.io = ioMgr.Open("GPIB0::17::INSTR")
Ena.io.timeout = 10000
' Check whether file name textbox is empty or not
If TextBox1.Text <> "" Then
File_Name = Trim(TextBox1.Text)
File_Type = Trim(frmFileSave.ComboBox1.Value)
' Open connection to the ENA
Select Case File_Type
Case "1: State (State Only)"
Ena.writestring ":MMEM:STOR:STYP STAT", True
Ena.writestring ":MMEM:STOR """ & File_Name & ".sta""", True
Case "2: State (State & Cal)"
Ena.writestring ":MMEM:STOR:STYP CST", True
Ena.writestring ":MMEM:STOR """ & File_Name & ".sta""", True
Case "3: State (State & Trace)"
Ena.writestring ":MMEM:STOR:STYP DST", True
Ena.writestring ":MMEM:STOR """ & File_Name & ".sta""", True
Case "4: State (All)"
Ena.writestring ":MMEM:STOR:STYP CDST", True
Ena.writestring ":MMEM:STOR """ & File_Name & ".sta""", True
Case "5: Trace Data (CSV)"
Ena.writestring ":MMEM:STOR:FDAT """ & File_Name & ".csv""", True
Case "6: Screen Image (BMP)"
Ena.writestring ":MMEM:STOR:IMAG """ & File_Name & ".bmp""", True
Case Else
MsgBox "Error in code"
End Select
Ena.io.Close
Else
MsgBox "Please enter a filename"
End If
End Sub
Private Sub UserForm_Initialize()
ComboBox1.AddItem "1: State (State Only)"
ComboBox1.AddItem "2: State (State & Cal)"
ComboBox1.AddItem "3: State (State & Trace)"
ComboBox1.AddItem "4: State (All)"
ComboBox1.AddItem "5: Trace Data (CSV)"
ComboBox1.AddItem "6: Screen Image (BMP)"
ComboBox1.ListIndex = 0
TextBox1.Text = "D:\TempFile"
End Sub