Home »
VB.Net »
VB.Net Programs
VB.Net program to insert or enqueue the elements into QUEUE using the collection
By Nidhi Last Updated : November 15, 2024
Insert elements into a Queue in VB.Net
Here, we will use Enqueue() method of the Queue collection class to add or insert an item into the queue.
Program/Source Code:
The source code to insert or enqueue the elements into QUEUE using collection is given below. The given program is compiled and executed successfully.
VB.Net code to insert or enqueue the elements into QUEUE using the collection
'VB.Net program to insert or enqueue the elements
'into QUEUE using collection.
Imports System
Imports System.Collections
Module Module1
Sub Main()
Dim queue As New Queue(5)
queue.Enqueue("India")
queue.Enqueue("USA")
queue.Enqueue("UK")
queue.Enqueue("CHINA")
Console.WriteLine("Items are added or enqueued into Queue.")
End Sub
End Module
Output
Items are added or enqueued into Queue.
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, And, we created an object of the Queue collection class for 5 elements. After that, we inserted 4 items using the Enqueue() method and then printed the "Items are added or enqueued into Queue" on the console screen.
VB.Net Data Structure Programs »