Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need to Read, Copy and Close in Background. MS XP is OS

jimarnettjimarnett Posts: 1Member
This is from my friend in England, who needs a small amount of help with his website. Can you help?

"I need to write in Visual Basic, or C++, or any other variation that is acceptable to Windows XP, a routine to do the following (for a web site that records ships that have been lost at sea during wartime):
1. I have a text file, "month.txt" containing the name of the month file .
2. I wish the programme to read the text file and copy the file that it finds there to a new file called "month.xls"
3. I wish the programme to run in the background and close when it has finished.

Background Note: I have been writing Excel files to handle an enormous amount of data which has necessitated the use of vbscript.
My original pan was to create batch files to load various data sources according to the date.
The vbscripts work OK but Windows XP does not seem to run batch files except manually through Explorer - in which case it all works.
I have tried various compilations but all the .exe files that I have created suffer from the same fate.
I think that basically the Windows XP environment shuns DOS based applications.
Thanks very much!

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : This is from my friend in England, who needs a small amount of help with his website. Can you help?
    :
    : "I need to write in Visual Basic, or C++, or any other variation that is acceptable to Windows XP, a routine to do the following (for a web site that records ships that have been lost at sea during wartime):
    : 1. I have a text file, "month.txt" containing the name of the month file .
    : 2. I wish the programme to read the text file and copy the file that it finds there to a new file called "month.xls"
    : 3. I wish the programme to run in the background and close when it has finished.
    :
    : Background Note: I have been writing Excel files to handle an enormous amount of data which has necessitated the use of vbscript.
    : My original pan was to create batch files to load various data sources according to the date.
    : The vbscripts work OK but Windows XP does not seem to run batch files except manually through Explorer - in which case it all works.
    : I have tried various compilations but all the .exe files that I have created suffer from the same fate.
    : I think that basically the Windows XP environment shuns DOS based applications.
    : Thanks very much!
    :

    Open a new VB project, add a module, kill the form (eg remove it), add a Sub Main() to the module, go to project settings and set startup object to Sub Main().
    Put all the code that needs to be run in this sub. Once you exit Sub Main, the program terminates.
    Now all you need to do is run the program and it'll do a lot of background things. Bad thing about this approach is that there is no debug info or anything. You could possibly use a form to atleast show what's happening.

    Now about opening the file, I'd use the Open statement. Look into it - if you're still stuck with it by the end of the week I'll post a piece of code (I have a good example/explanation on another computer).

    Copy is done by FileCopy

    Now all that remains is to make sure the program starts at some point.
    If you want the program to stay 'alive' in the background then you'll need to change how you handle Sub Main() / a form.

    Best Regards,
    Richard

Sign In or Register to comment.