是否可以将代码包装在一个块中以在调用一个变量的同时执行整个块?

Is it possible to wrap code in a block to execute whole block while calling one variable?

我有几行代码想在我的脚本中执行几次。

objFSO.CreateTextFile (path & statFile)
Set objFile = objFSO.OpenTextFile (path & statFile, 8)
objFile.Write strLine
objFile.Close

是否可以为其分配一个变量(或其他东西),这样我就不必一直写所有 4 行?

我知道条件语句,但真的没有条件。另一方面,我可以尝试通过将它与始终为真的东西一起使用来欺骗 IF。 我什至可以分配给 a 之类的 = if...then?

将可重复使用的代码放入 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