Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 26th, 2005, 9:48 PM   #1
genxweb
Newbie
 
Join Date: Sep 2005
Posts: 10
Rep Power: 0 genxweb is on a distinguished road
txt file into a variable

I am need of help to have a project read a txt file line by line and use each line as a variable ina loop.

IE.

txt file has the following info
calc.exe
test.exe
bad.exe

I want to do a loop

where it reads calc into a variable and then issues a comamnd such as kill varaiable then read the next line test and kills test.exe and have it go through until the lsit is complete. i can do this in shell scripting and perl but I need to do it in vb and it is driving me crazy any help or references be greatly appreciated.
genxweb is offline   Reply With Quote
Old Oct 26th, 2005, 10:10 PM   #2
puresnow
Newbie
 
Join Date: Oct 2005
Posts: 1
Rep Power: 0 puresnow is on a distinguished road
too difficult for me.
puresnow is offline   Reply With Quote
Old Oct 26th, 2005, 11:11 PM   #3
genxweb
Newbie
 
Join Date: Sep 2005
Posts: 10
Rep Power: 0 genxweb is on a distinguished road
what a wonderful first post HAHA. If any one can help please let me know. Iam going through my source code server now casue I know I did this about 4 years ago. Iam just real rusty and I am trying to reteach myself vb.
genxweb is offline   Reply With Quote
Old Oct 27th, 2005, 11:06 AM   #4
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
A particular line of a string, is Split(MyString, vbCrLF)(n) where n is the line number. Thus
Dim Lines() as String
Dim Iterator as Integer
Dim CurrentFile as String
Lines = Split(MyString, vbCrLF)
For Iterator = Lbound(Lines) To Ubound(Lines)
CurrentFile = Trim(Lines(Iterator))
If Len(CurrentFile) > 0 Then Kill CurrentFile
Next
Rory is offline   Reply With Quote
Old Oct 27th, 2005, 11:12 AM   #5
genxweb
Newbie
 
Join Date: Sep 2005
Posts: 10
Rep Power: 0 genxweb is on a distinguished road
Rory thanks. Though it looks like you are killing the file itself. Will this read the files contents line by line and kill the files based off the file name on each line.

Thanks for the help.
genxweb is offline   Reply With Quote
Old Oct 27th, 2005, 12:51 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Ok...

Load the contents of the textfile into the variable MyString first, this was just to demonstrate a way of iterating through each line. May I ask what this is for?
Rory is offline   Reply With Quote
Old Oct 27th, 2005, 1:28 PM   #7
genxweb
Newbie
 
Join Date: Sep 2005
Posts: 10
Rep Power: 0 genxweb is on a distinguished road
Iam trying to have a list of executables stored on a server in a txt file and have the client app dl the file then cycle through it stopping the process if it is running. I am shelling the names to pskill to stop the process. if you can point me to a sample of this let me know. The text file will always have the same name.

Thanks
Mike
genxweb is offline   Reply With Quote
Old Oct 27th, 2005, 5:50 PM   #8
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Sounds like it'd be quicker to do a batch file to me, For loop will iterate through file lines. If you're gonna write something in VB, at least elevate to the SE_DEBUG privilege and use the TerminateProcess API...
Rory is offline   Reply With Quote
Old Oct 28th, 2005, 8:48 AM   #9
genxweb
Newbie
 
Join Date: Sep 2005
Posts: 10
Rep Power: 0 genxweb is on a distinguished road
Rory I think I been asking what I want to do wrong. I thought about this last night. I want to ahve the text file populate a listbox and have the list box using a timer load from top down one at a time each word into a text box then remove that word from teh lsit and text box and move on to the next word. At which time I will use the txtbox.text in my shell code.

Thanks
Mike
genxweb is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:39 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC