![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 10
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Oct 2005
Posts: 1
Rep Power: 0
![]() |
too difficult for me.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2005
Posts: 10
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#4 |
|
Expert Programmer
|
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 |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Sep 2005
Posts: 10
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#6 |
|
Expert Programmer
|
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? |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Sep 2005
Posts: 10
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#8 |
|
Expert Programmer
|
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...
|
|
|
|
|
|
#9 |
|
Newbie
Join Date: Sep 2005
Posts: 10
Rep Power: 0
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|