View Single Post
  #1  
Old 15-12-2009, 11:06 PM
.BZU.'s Avatar
.BZU. .BZU. is offline


 
Join Date: Sep 2007
Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute
Default Program for Linear Search in an Array VB Code (By Sheraz)

Code:
 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
Reply With Quote