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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB5 ASCII File Transfer? 1

Status
Not open for further replies.

bromy

Programmer
Apr 12, 2000
3
US
I am working on a project that will move (Transfer) an ASCII comma delimited file.<br>Example: (This is not my actual code)<br>I have some <br>Check1_Click() = file1.txt<br>Check2_Click() = file2.txt<br>Check3_Click() = file3.txt<br>Based on what is checked the batch program will execute and transfer the files as shown below.<br><br>U:\file1.txt (Mapped Network Drive) to<br>I:\DISBUR&nbsp;&nbsp;&nbsp;&nbsp;(Another Mapped AS400 Drive).<br><br>I am using WindowsNT4.0 and using a MS-DOS batch file to make this happen, however a batch file does not work well in NT.&nbsp;&nbsp;I cannot find any MOVE commands anywhere that deals directly with files in VB5.&nbsp;&nbsp;Is there any code or resources out there that would have the information I am needing? Does Visual Basic 5 even have a function or some samples relating to this? Any suggestions would help out tremendously. I apologize for my inexperience and lack of knowledge.<br>Thanks, Bromy
 
This may be what you are looking for:<br><br>SourceFile$ = &quot;U:\&quot; & file1.txt<br>DestinationFile$ = &quot;I:\DISBUR\&quot; & file1.txt<br>FileCopy SourceFile$, DestinationFile$<br>DoEvents<br>If MsgBox(&quot;Are you sure you want to delete this file?&quot;, VbYesNo) = VbYes then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Kill SourceFile$<br>End If<br><br>Hope this helps. <p> <br><a href=mailto: > </a><br><a href= temporary Vorpalcom home page</a><br>Send me suggestions or comments on my current software project.
 
I found some more code and I was wondering why this doesn't work? I get a Object required Error? Do you have any insight?<br>Thanks in advance!<br><br>Private Sub Command1_Click()<br>&nbsp;&nbsp;&nbsp;&nbsp;'Move a file<br>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo error<br>&nbsp;&nbsp;&nbsp;&nbsp;FileCopy StartPath$ = &quot;U:\MALDER\DISBURSEMENTS\&quot; & microtel.txt, EndPath$ = &quot;I:\DISBFLR\&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Kill StartPath$<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br>error:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox Err.Description, vbExclamation, &quot;Error&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub
 
StartPath$ and EndPath$ variables should be defined before the FileCopy command. Then you would use FileCopy StartPath$, EndPath$. Using &quot;I:\DISBFLR\&quot; would give you a Path File Access error because FileCopy only works with files, not directories. &quot;I:\DISBFLR\File1.txt&quot; would work but VB would get a little confused with &quot;I:\DISBFLR\&quot; & File1.txt (I didn't catch that in your first post).<br>Also you are using the key word &quot;Error&quot; as a line label in an error handler. The results may unpredictable. Best to name the line something else, like &quot;ErrorHandler:&quot; and place it on a line by itself to avoid ambiguity.<br><br>Good luck. <p> <br><a href=mailto: > </a><br><a href= temporary Vorpalcom home page</a><br>Send me suggestions or comments on my current software project.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top