\\\
Dim FileIn() As String = ...
Array.Sort(FileIn)
Dim Index As Integer = Array.BinarySearch(FileIn, "window")
///
'BinarySearch' will only make sense for a sorted array. For unsorted
arrays, a linear search would be the "best" choice, but this would mean that
the item you are looking for is compared to all items in the list until the
item is found. This algorithm has a runtime of O(n) for n items and thus is
very slow for large arrays. Nevertheless, it's faster than sorting and then
using binary search. Binary search makes sense if you are searching several
times.
There are in dotnet so many arrays, when it is created as this (a fixed
array )
dim FileIn(Counter) as String
Than it can be something as
\\\
dim i as integer
For i = 0 to FileIn.length
if FiliIn(i) = "window" then
exit for
Next
///
i is the place where it is, assuming you loaded it with a zero index as
starter.
In addition to the other responses, you can use the IndexOf method of
the Array class, but it would not be suitable if your array had
duplicate entries:
MsgBox(Array.IndexOf(MyArrayVar,"window").ToString)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.