View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Testing for a string of zero bytes

Hi,

If InStr(mystring, "1") Then
MsgBox "contains ones"
Else
MsgBox "all zeroes"
End If

Mike

"simonc" wrote:

I am reading a series of bytes (around 2000) from a binary file and want the
quickest way to test if all the bytes have a value zero. Would this be by a
string comparison? I'm sure reading the bytes into a byte array and testing
each one individually is NOT the best way. Incidentally I have to repeat this
operation several hundred thousand times so any gain in speed will be
significant.

Grateful for advice.