I am trying to copy the file I need from the server in this case the location of my server is J:\IO\qebsfnam\pass2ebs and convert this file to pass2ebs.txt and test it if this file exit or not. Can someone take a look at this code and advise me where i made a mistake.I highlighted part of the code where i encounter an error message. thanks
Private Sub Command1_Click()
Dim p1 As Integer
Dim L As Integer
Dim I As String
Dim FileString As String
Dim T As String
Copy "J:\IO\qebsfnam\pass2ebs pass2ebs.txt"
Rem Open "J:\IO\qebsfnam\pass2ebs" For Input As #1
If Dir(pass2ebs.txt")<>"" then
Open "pass2ebs.txt" For Input As #1
Else
Message = "File not found"
Open "C:\pass2ebs.txt" For Input As #1
Open "C:\pass.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, FileString
L = Len(FileString)
p1 = InStr(FileString, "/")
I = LTrim(Left(FileString, 6))
If (I = "ITEM01" And p1) Then
If Mid(FileString, p1 - 4, 1) <> "." Then
FileString = Left(FileString, p1 - 4) & "." & Right(FileString, L - p1 + 4)
Print #2, FileString
Else: Print #2, FileString
End If
Else: Print #2, FileString
End If
Loop
Close #1
Close #2
Kill "C:\pass2ebs.txt"
Name "C:\pass.txt" As "C:\pass2ebs.txt"
End Sub
Private Sub Command1_Click()
Dim p1 As Integer
Dim L As Integer
Dim I As String
Dim FileString As String
Dim T As String
Copy "J:\IO\qebsfnam\pass2ebs pass2ebs.txt"
Rem Open "J:\IO\qebsfnam\pass2ebs" For Input As #1
If Dir(pass2ebs.txt")<>"" then
Open "pass2ebs.txt" For Input As #1
Else
Message = "File not found"
Open "C:\pass2ebs.txt" For Input As #1
Open "C:\pass.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, FileString
L = Len(FileString)
p1 = InStr(FileString, "/")
I = LTrim(Left(FileString, 6))
If (I = "ITEM01" And p1) Then
If Mid(FileString, p1 - 4, 1) <> "." Then
FileString = Left(FileString, p1 - 4) & "." & Right(FileString, L - p1 + 4)
Print #2, FileString
Else: Print #2, FileString
End If
Else: Print #2, FileString
End If
Loop
Close #1
Close #2
Kill "C:\pass2ebs.txt"
Name "C:\pass.txt" As "C:\pass2ebs.txt"
End Sub