AnsweredAssumed Answered

E5071c A program error about double open file

Question asked by ethan1208g@yahoo.com.tw on Jan 21, 2014
Latest reply on Jan 21, 2014 by ethan1208g@yahoo.com.tw
Sorry about my pool english. I will do my best to explane my question.
What i want to do is when i press button , it will open a file and get data from E5071c.
The part of Getting data from E5071c is fine in the first time , 
but when i press button the second time , it will show "file already open"
i try to use "for / when " to let the pragram only open a file once,but it doesn't work
Can anybody help me , thanks very much!!!!





The program what i use as below  

Private Sub CommandButton1_Click()

Dim c As Integer
Dim i As Integer


'Open a file to write the data
MyFile = "D:\marker" + ".xls"
fnum = FreeFile()
Open MyFile For Output As #fnum


'Read Marker X axis value
X_val = SCPI.CALCulate(2).SELected.MARKer(1).X

'Write X axis value
Print #fnum, "Frequency = " + CStr(X_val); "Hz"

'Read the markers from Traces & marker 1-4 and write data to file
For i = 1 To 4
For c = 1 To 4

SCPI.CALCulate(2).PARameter(i).SELect
mVal = SCPI.CALCulate(2).SELected.MARKer(c).Y

Print #fnum, "Trace " + CStr(i) + ", "; "Marker:" + CStr(c); " " + CStr(mVal(0)); ""
Next c
Next i

Print #fnum, "----------------------------------------------------------------"

End Sub

'exit
Private Sub CommandButton2_Click()

End

End Sub  

Outcomes