Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old October 22nd, 2003, 07:38 PM
dnfrantum dnfrantum is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: CA
Posts: 3 dnfrantum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Can't seem to figure this out...

I think the logic looks good, but would really benefit from a second set of eyes.

here is the code
Code:
Option Explicit

Private Sub Form_Load()
Call ShowFileList("D:\ftp\FedEx\Invoices")
tstTimer1.Interval = 60000
End Sub
Private Sub ShowFileList(folderspec)
    Dim fs, f, f1, fc
    Dim FedEx1
    Dim FedEx2 As String
    Dim FedEx3
    Dim FedExFile
    Dim Counter As Long
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("D:\ftp\FedEx\Invoices")
    Set fc = f.Files
    
    On Error Resume Next
    For Each f1 In fc
      If fs.FileExists("D:\ftp\FedEx\invoices\fxInvDetRec.txt") Then
         fs.DeleteFile ("D:\ftp\FedEx\invoices\fxInvDetRec.txt")
      End If
      If fs.FileExists("D:\ftp\FedEx\invoices\" & f1.Name) And f1.Name <> "D:\ftp\FedEx\invoices\fxInvDetRec.txt" Then
         fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive" & f1.Name
         fs.MoveFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\fxInvDetRec.txt"
         Call run_FedEx_Invoice_Detail_Record_Import
         FedEx1 = Shell("D:\ftp\FedEx\RECV_INVOICES.cmd")
         Counter = 1
      Else
         FedEx1 = Shell("D:\ftp\FedEx\RECV_INVOICES.cmd")
         Counter = 1
      End If
   Next
End Sub
Private Sub tstTimer1_Timer()

Static Counter As Long
   tstTimer1.Enabled = False
   Do While Counter >= 60
      tstTimer1.Enabled = False
      Call ShowFileList("D:\ftp\FedEx\Invoices\")
   Loop
   Counter = Counter + 1
   
End Sub


Essentially, this is what I am attempting to do. I have x number of files in the path D:\FTP\FedEx\invoices\. I want to take those files one by one and copy them to the archives and then rename them to D:\FTP\FedEx\invoices\fxInvDetRec.txt. I have to use this name as the DTS package that I am using only recognizes one named file per connection. I want this to continue until the last file that is not D:\FTP\FedEx\invoices\fxInvDetRec.txt is processed. I then want to get any new files that may be waiting for the next processing time.

What do you think?

Reply With Quote
  #2  
Old October 23rd, 2003, 09:58 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I have 2 problem about your code:
1.what's the "RECV_INVOICES.cmd"? If it's not a execute file,Shell call will return error!
2.U should add "\" in the statement:
fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive\" & f1.Name

Reply With Quote
  #3  
Old October 23rd, 2003, 10:04 AM
dnfrantum dnfrantum is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: CA
Posts: 3 dnfrantum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for your reply, but the .cmd file is executing correctly. It is similar to .bat file and shell isn't having a problem with it. As far as the additional '/', I really want the file to be renamed to archive & f1.name

Reply With Quote
  #4  
Old October 23rd, 2003, 08:34 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Oh,My mean is u should add "\" in the statement:fs.CopyFile "D:\ftp\FedEx\invoices\" & f1.Name, "D:\ftp\FedEx\invoices\Archive\archive" & f1.Name

because this statement lack "\" after the dircetory and before the f1.name...

Reply With Quote
  #5  
Old October 24th, 2003, 02:49 AM
Unkie Unkie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 32 Unkie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 27 sec
Reputation Power: 5
Whats the use of the static counter? in the while loop you don't change it, ...
you increase it even more so it will be always >= 60...

Reply With Quote
  #6  
Old October 24th, 2003, 11:37 AM
dnfrantum dnfrantum is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: CA
Posts: 3 dnfrantum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
unkie, you are correct. I needed to add a reset in there and I did. I am using the timer control, so I need the static counter. I have it working now. I am still having some issues, but that isn't one of them.

Reply With Quote
  #7  
Old October 27th, 2003, 05:18 AM
Unkie Unkie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 32 Unkie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 27 sec
Reputation Power: 5
you could try to replce the on error move next to on error msgBox err.Description
this way the errors won't be hidden, if i'm not terribly mistaken ^^

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Can't seem to figure this out...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway