Location: near Govt College of Science Multan Pakistan
Posts: 9,675
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
Program for Linear Search in an Array VB Code (By Sheraz)
Module Module1 Sub Main() Dim ar As Integer() Dim flag As Integer = 0 Dim to_search As Integer ar = New Integer() {15, 8, 1, 6, 34, 7, 5, 342, 4, 7} Console.WriteLine("Please enter the integer that you want to search") to_search = Console.ReadLine() For i = 0 To ar.GetUpperBound(0) If to_search = ar(i) Then flag = 1 Exit For 'Optional, to exit from loop when condition is true first time End If Next If flag = 1 Then Console.Write("The element {0} exists in the array", to_search) Else Console.Write("The element {0} doesn't exist in the array", to_search) End If Console.ReadLine() End Sub End Module
__________________
(¯`v´¯) `*.¸.*` ¸.*´¸.*´¨) ¸.*´¨) (¸.*´ (¸.Bzu Forum
Don't cry because it's over, smile because it happened
Best view in Firefox Almuslimeen.info | Cloud Computing | Dedicated server hosting Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.