I don't think there is such a thing in dot not for a normal array.
You should consider replacing your array by and ArrayList. The arraylist is much more efficient. It's collection based, and has a binary search with which you could locate you value.
If myArray.BinarySearch("item1") >= 0 Then
MessageBox.Show("Fount it")
End If
' BinarySearch returns the index of the occurence... so if it's less then 0, it hasn't find it. Also, because it's a BinarySearch, you must sort the list first. If not it will not work properly.
just for the record..
hashtables are much faster since it uses..well..hash tables for storing data. since a unique hashcode (for all practical purposes) is generate from the key for each item stored in the hashtable, searching for an element (the key) is very fast especially if the data structure is going to store a lot of elements.
while the worst case search time for a binary search is O(nLog(n)) that of a search operation in hashtable is O(n) where n is the number of elements in the data structure. In fact, for most practical purposes since the hashcode will be unique for each element in the hashtable, the search time is O(1) which is very fast compared to binary search.
Oh and yes - you don't even need to sort the elements in the hashtable to do a fast search unlike the binarysearch in an arraylist or any other data structure.
imy79 that is true until one point. The bigger the hash table gets, the less efficient it is. There is a point after X number of items that the ArrayList will become faster and more efficient.
The larger the number of elements, the higher the value of log(n) gets in which case O(log(n)) means its going to take longer to search for the binary search. On the other hand, the hashtable has an almost constant time for retrieving an element irrespective of the number of elements since it has a running time of O(1).
Imran.
0
SpanxxxCommented:
Barring you are referring to your array as a whole and not just an item in the array, here is the easy .Net way to check.
If array.length > 0 then
'array is not empty
Else
'array is empty
End If
and repeating the first comment, with a little more info
dim exeName as string
exeName = Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf("\") + 1)
0
drakkarnoirAuthor Commented:
Thanks to all :)
0
Featured Post
It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.
Application.ExecutablePath
If you don't want the path, just use the string.substring to get your executable name.
You can also use Application.ProductName(),
Andre,
MCSD