Do Until...Loop

上一篇 / 下一篇  2010-03-23 17:46:41 / 个人分类:VBScript

Do Until...Loop

Do...Loop enables the script. to continue to perform. certain actions until a specific condition occurs. Do While...Loop enables your script. to continue to perform. these actions as long as the specified condition remains true. Once the specified condition is no longer true, Do While...Loop exits. In contrast, Do Until...Loop has the opposite effectthe script. continues to perform. the action until a certain condition is met.

Example:ReadTextFile.vbs

'header information section and on error resume next, define the variables
Option Explicit
On Error Resume Next
Dim strError
Dim objFSO
Dim objFile
Dim strLine
Dim intResult

'define the constant ForReading and strError
CONST ForReading = 1
strError = "Error"
'connection filesystemobject,open the text file by forreading method
Set bjFSO = CreateObject("Scripting.FileSystemObject")
Set bjFile = objFSO.OpenTextFile("C:\windows\setuplog.txt", ForReading)
'read every line with the text
strLine = objFile.ReadLine

Do Until objFile.AtEndofStream
  strLine = objFile.ReadLine
  intResult = InStr(strLine, strError)
  If intResult <> 0 Then
  WScript.Echo(strLine)
  End If
Loop
WScript.Echo("all done")
objFile.Close

 

  

 

From
Microsoft® VBScript. Step by Step
By Ed Wilson

 

 


TAG:

 

评分:0

我来说两句

Open Toolbar