Skip to content
This repository was archived by the owner on Dec 29, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Linear search is a very simple search algorithm. In this type of search, a seque
|20| [Marco Wang](https://github.com/aesophor) | University of Taipei | Taiwan | Java, C, Bash, Python-3 |
|21| [Grzegorz Wcisło](https://github.com/grzegorz-wcislo) | | Poland | |
|22| [Ivan Dyominov](https://github.com/dyominov) | | Ukraine | Scala |
|23| [Pranav Bhardwaj](https://github.com/pranav1999) | Maharaja Surajmal Institute | India | VB.NET |
3 changes: 3 additions & 0 deletions vb-linear-search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# vb-linear-search

Open file in Visual Studio as console application and run the code.
43 changes: 43 additions & 0 deletions vb-linear-search/vb-linear-search.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Module LinSearchFunc

Sub Main()
Console.WriteLine("Linear Searching using Function")
Console.WriteLine()
Dim n, i, k, item As Integer
Console.Write("Enter Number of Elements: ")
n = CInt(Console.ReadLine)
Dim arr(n) As Integer
Console.WriteLine()
For i = 0 To n - 1
Console.Write("Enter Element(" & (i + 1) & "): ")
arr(i) = CInt(Console.ReadLine)
Next
Console.WriteLine()
Console.WriteLine("Before Sorting")
Console.WriteLine()
For i = 0 To n - 1
Console.WriteLine("Element in (" & i & "): " & arr(i))
Next

Console.WriteLine()
Console.Write("Enter the Element to be searched:")
item = CInt(Console.ReadLine())
k = linear_search(arr, n, item)
Console.WriteLine()
If k <> -1 Then
Console.WriteLine("Element is Found")
Else
Console.WriteLine("Element is Not Found ")
End If
Console.ReadLine()
End Sub
function linear_search(byval x() as integer,byval y as integer,byval z as integer)
Dim j As Integer
For j = 0 To y - 1
If x(j) = z Then
Return j
End If
Next
Return -1
End Function
End Module