function binsearch( array() as integer, target as integer ) as integer 'returns the index of the target number, or -1 if it is not in the array dim as uinteger lo = lbound(array), hi = ubound(array), md = (lo + hi)\2 if array(lo) = target then return lo if array(hi) = target then return hi while lo + 1 < hi if array(md) = target then return md if array(md)