I'm writing a VB5 program in which I have to download data from the company's mainframe computer (in the form of .txt files) and then modify that data into a Access database. I can do everything but one thing- which is killing me.

When I Shell the program which begins to download the data from the mainframe to the local computer- I dont know when I can tell my vb program it's safe to continue. The size of the text file varies from month to month (its never the same size- so some months it could take seconds to download and other months it could take hours). I have to somehow make it so that VB recognises NOT when the file exists BUT WHEN THE FILE SIZE OF THE FILE STOPS CHANGING (therefore we know the file download is complete). I'm using the below code (please feel free to eithier modify it or provide a different code that would work). BTW- the file that I'm working with is "C:\rbsscs\cusms.txt"


Function FileDownloaded(FileName as String)

Dim tmrInterval&, X&,Y&
On Error Resume Next
X& = 1
Do While X& <> Y&
tmrInterval& = Timer
X& = FileLen("C:\rbsscs\cusms.txt")
Do Until Timer - tmrInterval& >= 5
DoEvents
Loop
Y& = FileLen("C:\rbsscs=cusms.txt")
Loop

Where in the above code is the best place can I add the code that is used once the file is done downloading (mainly the sendkeys funtion to exit out of the other download program)

PLEASE HELP,
PLEASE,
Brandr Beekman
[email protected]