A
A
Ansh-spb2018-10-10 11:54:12
VBScript
Ansh-spb, 2018-10-10 11:54:12

VBS: Assigning a value to a variable from a line in another file?

There is a text file in the network folder \\ServerShara\1.txt
How can a VBS script take a value for variables, let 's say
strText1 = 1st line from file 1.txt on the ball, and variable
strUrl1 = 2nd line from file 1.txt on the ball?
is it possible at all and how specifically to specify that the variable is equal to the entire first line from the text file?
This is necessary in order not to change the script every time, but so that the manager can edit the lines in Txt and the script will work with new values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JaxxDexx, 2018-10-10
@Ansh-spb

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\ServerShara\1.txt", ForReading)

strText1 = objTextFile.ReadLine
strUrl1 = objTextFile.ReadLine

objTextFile.Close

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question