Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using external parameters file in VB

Status
Not open for further replies.

RobBentley

IS-IT--Management
May 10, 2003
199
Hi,

I've quite happily written a graphical front end for some old command line software we have that writes out a config file and calls them at the command prompt.

Currently my application has a config.set file (which is basically a text file) with 1 line in it. This tells the program where the command line exe is. I read the whole file as a variable and use that when launching the cmd app.

I now want to put 3-4 different parameters into the file. So I want say 3 lines in a text file and I want the entire of line 1 to go into a variable, the entire of line two into another variable (etc etc).

How can I easily do this?


Cheers in advance.

Rob

 
Not tested....

For this method, you'll need a reference to "Microsoft Scripting Runtime"

Code:
Dim FSO As Scripting.FileSystemObject
Dim sTemp As String
Dim arTemp As String

Set FSO = CreateObject("Scripting.FileSystemObject")
sTemp = FSO.OpenTextFile("C:\Path\File.ext", ForReading).ReadAll
Set FSO = Nothing

arTemp = Split(sTemp, vbCrLf)

Debug.Print "Line1: " & arTemp(0)
Debug.Print "Line2: " & arTemp(1)
Debug.Print "Line3: " & arTemp(2)

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Another quick question... if the location of the text file was already set in a variable, how would I format that text?

sTemp = FSO.OpenTextFile("C:\Path\File.ext", ForReading).ReadAll


would it be?

sTemp = FSO.OpenTextFile(VariableName, ForReading).ReadAll


 
yes

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top