Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the LINQ Query
Here, we are going to demonstrate the LINQ Query in VB.Net.
Submitted by Nidhi, on January 24, 2021 [Last updated : March 08, 2023]
VB.Net – LINQ Query
In this program, we will create a LINQ query to get the numbers greater than or equal to 30 from an integer array and print them on the console screen.
Program/Source Code:
The source code to demonstrate the LINQ Query is given below. The given program is compiled and executed successfully.
VB.Net code to demonstrate the example of LINQ Query
'VB.NET program to demonstrate the LINQ Query.
Imports System
Imports System.IO
Imports System.Linq
Module Module1
Sub Main()
Dim intVals() As Integer = {10, 20, 30, 35, 40, 50, 60}
Dim result = From val In intVals Where val >= 30
Console.WriteLine("Result: ")
For Each val As Integer In result
Console.Write(val & " ")
Next
Console.WriteLine()
End Sub
End Module
Output
Result:
30 35 40 50 60
Press any key to continue . . .
Explanation
In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.
In the Main() function, we created an integer array that contains 7 elements. Here, we executed the LinQ query and get numbers greater than equal to 30 from the array and then print the result on the console screen.
VB.Net LINQ Query Programs »