1 Replies - 5434 Views - Last Post: 24 April 2007 - 06:35 AM Rate Topic: -----

#1 jaxxstorm  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 23-April 07

Searching an Array

Posted 24 April 2007 - 01:36 AM

Hi, quick question hopefully will be answer before 10.

I've got a list box populated from an array with membership numbers and a name in the list box.

I want to create a function to search the array and return a boolean value of true of false.
The boolean value is membershipno
The Listbox is populated like so;

 Dim Myfile(99) As String

		Dim Count As Integer = 0
		'declare stream reader object connected to the fiel
		Dim objReader As New System.IO.StreamReader("myfile.txt")
		'initailise array counter
		Do While objReader.Peek <> -1
			Myfile(Count) = objReader.ReadLine
			Count += 1

Can I use InStr to search the file, and if so, how do I do it? Is there another function like Binary Search which is easier?

Is This A Good Question/Topic? 0
  • +

Replies To: Searching an Array

#2 tody4me  Icon User is offline

  • Banned
  • member icon

Reputation: 12
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: Searching an Array

Posted 24 April 2007 - 06:35 AM

try this:
loop through the array from low bound index (get lbound) to high bound index (get ubound)
if value you are looking for = the current value in question
return that value
if you make it through the entire array without finding the value, the value returned would be false, or -1, or 0 if the lbound is 1.

if you need more help, show some work on the function

This post has been edited by tody4me: 24 April 2007 - 06:36 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1