Permalink
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (60 sloc) 2.65 KB
title ms.date ms.prod ms.reviewer ms.suite ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
Take While Clause (Visual Basic)
2015-07-20
.net
devlang-visual-basic
article
vb.QueryTakeWhile
VB
queries [Visual Basic], Take While
Take While clause
Take While statement
db8f9f2f-fc9f-4a6c-b0b8-1bf048147e11
14
dotnet-bot
dotnetcontent
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Take While Clause (Visual Basic)

Includes elements in a collection as long as a specified condition is true and bypasses the remaining elements.

Syntax

Take While expression  

Parts

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.

Remarks

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.

Example

The following code example uses the Take While clause to retrieve results until the first customer without any orders is found.

[!code-vbVbSimpleQuerySamples#2]

See Also

Introduction to LINQ in Visual Basic
Queries
Select Clause
From Clause
Take Clause
Skip While Clause
Where Clause