Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18013
Number of posts: 55386

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need to Read, Copy and Close in Background. MS XP is OS Posted by jimarnett on 30 Jan 2007 at 10:45 AM
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!
Report
Re: Need to Read, Copy and Close in Background. MS XP is OS Posted by BitByBit_Thor on 30 Jan 2007 at 12:41 PM
: 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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.