Optimal String Array Search
Category:
C#, VB.NET, ASP.NETType:
SnippetsDifficulty:
IntermediateAuthor:
AnonymousVersion Compatibility: Visual Basic 6, Visual Basic.NET
More information:
If you have a string array sorted in ascending order, this code returns the index of the string found with the array. It returns -1 if the string is not found in the array. For large arrays, it uses a recursive function to locate the index by dividing the array in two. For small arrays it does a sequential lookup.
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: