While Wend Statement
The While Wend statement is a control structure that controls a repetitive action. It does not return a value. Siebel VB includes the While statement so that it is compatible with older versions of Visual Basic. If possible, it is recommended that you use the Do Loop statement instead. For more information, see Do Loop Statement.
Format
While condition
statement_block
Wend
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
condition |
A condition where Siebel VB runs the statements in a statement_block. |
statement_block |
A series of statements that Siebel VB runs while the value in the condition argument is TRUE. |
Example
The following example opens a series of files and looks for the following string in each file:
*Overdue*
This example uses the While Wend statement to loop through the c:\temP00? files. The CreateFiles subroutine creates these files:
(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