Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and Convert

Status
Not open for further replies.

dawtes

Programmer
Jun 23, 2005
31
US
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

 
You say, "I highlighted part of the code where i encounter an error message". I don't see this "highlight".

ciao for niao!

AMACycle

American Motorcyclist Association
 
sorry when I past it, it takes off the highlighted part..
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
 
Replace:
Code:
Copy "J:\IO\qebsfnam\pass2ebs     pass2ebs.txt"
with
Code:
Filecopy "J:\IO\qebsfnam\pass2ebs","pass2ebs.txt"

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
now it works fine thank you johnwm. My next question is after I run this sub routine i would like to invoke an excutable file "Gen.exe" inorder for me to create the final out put. I am just wondering if i just add the executable file before the End Sub.Thank you guys for the help

Private Sub Command1_Click()
Dim p1 As Integer
Dim L As Integer
Dim I As String
Dim FileString As String



FileCopy "J:\IO\qebsfnam\pass2ebs", "C:\pass2ebs.txt"

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
 
It's usually best to ask a new question in a new thread, but to run an external application, look up the Shell command

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top