Hello Everyone,
I have a program written in VB 6 running in Windows XP. My problem is I create a .dat file with the results of my test and save it to the c drive. I also want to save it to another drive on the server at the same time. Right now I am writing to the file and then I close it.(I think) Then I do a Filecopy MyFile, destination folder. When it executes that line of code I get a runtime error 75. The folder that I copy from is not read only and the file does exist. How do you close the file that I am trying to copy correctly? Here is the code I am using:
The last two lines will give me different runtime errors depending on the "\" at the end of the destination file. I don't know if I am closing MyFile right or not. I said I was saving a second copy to a remote server but you will notice that I am saving it to the c drive also. I am just doing this until I get the program installed in its final location.
Could it be the way I am opening MyFile to begin with? I open it For Append. Thanks in advance.
I have a program written in VB 6 running in Windows XP. My problem is I create a .dat file with the results of my test and save it to the c drive. I also want to save it to another drive on the server at the same time. Right now I am writing to the file and then I close it.(I think) Then I do a Filecopy MyFile, destination folder. When it executes that line of code I get a runtime error 75. The folder that I copy from is not read only and the file does exist. How do you close the file that I am trying to copy correctly? Here is the code I am using:
Code:
Sub ResultsToDisk(Side%)
Dim FileName As String
Dim Handle
Dim MaxNumTest As Integer
Dim Source As String
Dim n As Integer
Dim StartFileName As String
ErrMod = "ResultsToDisk"
MaxNumTest = SetGen(Side%, 3)
If MaxNumTest < SetGen(Side%, 4) Then MaxNumTest = SetGen(Side%, 4)
If MaxNumTest < SetGen(Side%, 5) Then MaxNumTest = SetGen(Side%, 5)
Handle = FreeFile
'Create file Name as todays date if it does not exist.
Call GetDataFileName(FileName) 'FileName = "5-20130130000.dat"
MyFile = "C:\Baldor\ModelData\Results\" & FileName 'DefaultDir & "motor\RESULTS\" & FileName
Open MyFile For Append As Handle
Write #Handle, MainView.LoadedModel(Side%).Caption, Format(Time, "hh:mm:ss AMPM"), '"Medium Time"),
Select Case TestStatus(Side%)
Case 1
Write #Handle, "PASS",
Case 2
Write #Handle, "ABORT",
Case 3
Write #Handle, "FAIL",
Case Else
Write #Handle, "ERROR",
End Select
Write #Handle, TestTemperature(Side%), ArcDetected(Side%), ResultsHipot(Side%, 0, 1),
Write #Handle, ResultsHipot(Side%, 1, 1),
For wz = 1 To MaxNumTest
Write #Handle, ResultsRes(Side%, wz, 1), ResultsPoles(Side%, wz, 1),
Write #Handle, ResultsRotDir(Side%, wz, 1), ResultsDegrees(Side%, wz, 1),
Write #Handle, ResultsSurge(Side%, wz, 0, 1), ResultsSurge(Side%, wz, 1, 1),
Next wz
Write #Handle,
Close #Handle
DelayThisMilSec 100
FileCopy MyFile, "C:\BaldorResults" 'This line gives me a runtime error '75'
'FileCopy MyFile, "C:\BaldorResults\" 'This line gives me a runtime error '76'
Could it be the way I am opening MyFile to begin with? I open it For Append. Thanks in advance.