Reputation: 71
I have few lines of code I would like to execute in my script on a couple of occasions.
objFSO.CreateTextFile (path & statFile)
Set objFile = objFSO.OpenTextFile (path & statFile, 8)
objFile.Write strLine
objFile.Close
Is it possible to assign a variable (or something) to it, so I don't have to write all 4 lines all the time?
I know about conditional statements, but there is really no condition. On the other hand I could try to cheat IF
by using it with something always true.
Can I even assign to, let's say, a
something like = if...then
?
Upvotes: 2
Views: 104
Reputation: 38755
Put the re-usable code in a Sub (or a Function):
>> Sub CalledOften()
>> WScript.Echo "Here I am again"
>> End Sub
>> For i = 1 To 3
>> CalledOften
>> Next
>>
Here I am again
Here I am again
Here I am again
Upvotes: 2