description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||
---|---|---|---|---|---|---|---|---|---|
Learn more about: Take While Clause (Visual Basic) |
Take While Clause |
07/20/2015 |
|
|
db8f9f2f-fc9f-4a6c-b0b8-1bf048147e11 |
Includes elements in a collection as long as a specified condition is true
and bypasses the remaining elements.
Take While expression
Term | Definition |
---|---|
expression |
Required. An expression that represents a condition to test elements for. The expression must return a Boolean value or a functional equivalent, such as an Integer to be evaluated as a Boolean . |
The Take While
clause includes elements from the start of a query result until the supplied expression
returns false
. After the expression
returns false
, the query will bypass all remaining elements. The expression
is ignored for the remaining results.
The Take While
clause differs from the Where
clause in that the Where
clause can be used to include all elements from a query that meet a particular condition. The Take While
clause includes elements only until the first time that the condition is not satisfied. The Take While
clause is most useful when you are working with an ordered query result.
The following code example uses the Take While
clause to retrieve results until the first customer without any orders is found.
[!code-vbVbSimpleQuerySamples#2]