Linq Lambda Expressions in Vb.net - Querying Data

This tutorial was created with Visual Studio .NET 2008,the FOR loop to display our selection:
but the results can be achieved in 2005 if Microsoft'sPrivate Sub Button1_Click(ByVal sender As
LINQ Community Technology Preview release isSystem.Object, ByVal e As System.EventArgs)
downloaded and installed from Microsoft.Handles Button1.Click
In this tutorial, we will be looking at VB.NET LambdaDim arrNames() As String = {"Mike", "Zach", "Ella", "Eli",
Expressions. We will see how we can sort data from"Jo"}
an array using the newly-introduced LambdaFor Each varName In arrNames.Where(Function(n)
Expressions in VB.NET. Lambda Expressions can ben.StartsWith(TextBox1.Text))
used in place of LINQ Queries, and can make theLabel2.Text = Label2.Text + varName & ", "
code a lot shorter. In this example, we will be creatingNext varName
an array and retrieving data from the array dependingEnd Sub
on user entry. We will create an array of names, thenThe string is defined and some names are added to it.
retrieve only the ones that start with a certain letter.We then initialize a FOR loop and select the data we
We will be creating this example in a Windows Form.want: this Lambda Expression is selecting all the
We will have one textbox for data input, one button tonames within the array that begin with the text that
initiate the call, and one label to display the output. Oncewas submitted to the textbox - if nothing is entered,
we have these controls on our form, we can begineverything will be returned and displayed.
coding. We can code everything into our OnClickPlease follow the link to for the continuation and code.
button event.Thanks and happy coding!!
First, we will initialize the string array. Then we can add