Siebel VB Language Reference > VB Language Reference >
While...Wend Statement
This standard VB control structure controls a repetitive action. Syntax
While condition statement_block Wend
|
|
condition |
A condition under which to execute the statements in statement_block |
statement_block |
A series of statements to execute while condition is TRUE |
Returns
Not applicable Usage
The While statement is included in Siebel VB for compatibility with older versions of Basic. The Do...Loop statement is a more general and powerful flow control statement. Example
This example opens a series of customer files and checks for the string *Overdue* in each file. It uses While...Wend to loop through the c:\temP00? files. These files are created by the subroutine CreateFiles . (general) (declarations) Option Explicit Declare Sub CreateFiles
Sub CreateFiles Dim odue as String Dim ontime as String Dim x Open "c:\temp001" for OUTPUT as #1 odue = "*Overdue*" ontime = "*On-Time*" For x = 1 to 3 Write #1, odue Next x
For x = 4 to 6 Write #1, ontime Next x Close #1 Open "c:\temp002" for Output as #1 Write #1, odue Close #1 End Sub
Sub Button_Click Dim custfile as String Dim aline as String Dim pattern as String Dim count as Integer Call CreateFiles Chdir "c:\" custfile = Dir$("temP00?") pattern = "*" + "Overdue" + "*" While custfile <> "" Open custfile for input as #1 On Error goto atEOF Do Line Input #1, aline If aline Like pattern Then count = count + 1 End If Loop nxtfile: On Error GoTo 0 Close #1 custfile = Dir$ Wend Kill "c:\temp001" Kill "c:\temp002" Exit Sub atEOF: Resume nxtfile End Sub
See Also
Do...Loop Statement
|