Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Binary Strings with InStrB

Status
Not open for further replies.

nik_imported

Programmer
Jan 11, 2000
5
0
0
US
I'm having a problem getting the InStrB function to work.&nbsp;&nbsp;I'm using VB5 and am reading a binary stream of data.&nbsp;&nbsp;I am putting the bytes in a byte array for processing.<br>I can get RightB, LenB, AscB, etc to work but InStrB returns nothing. I have tried searching the array and putting the array into another string and searching.<br>I have written a function to do this but am wondering if this is a VB bug or if I'm doing something silly.<br>Thanks,<br>Nick
 
Check if the file is opened correctly, (i.e. binary read), try using Instr instead of instrb, i couldn't find any info relating to instrb, but with instr, you have a parameter which indicates binary compare. <p> <br><a href=mailto: > </a><br><a href= </a><br>
 
Hello,<br>Thanks for replying.&nbsp;&nbsp;It's not a file, it's a stream of data via a comm port.&nbsp;&nbsp;I read it into a string and put the string into a byte array for processing.&nbsp;&nbsp;It's reading the input fine, however.&nbsp;&nbsp;I have tried putting it back into a string and using InStr with no luck.&nbsp;&nbsp;The binary versus text compare option is usually for case-sensitive searches, and not for binary data per se.&nbsp;&nbsp;(I think)<br>Nick
 
I am trying to use the Open method to open an exe, search for a binary string, update the string accordingly, and resave as exe. Reason for this is that I have to recompile to change a string (Ip address) everytime. I can do this with a hex editor but dont' want people jacking up my code so I figured if I could open as binary then I could give them a simple gui to change just what the want (IP). Here is what I have but dont' know how to pass #1 to something that I can open and manipulate. Thanks.

Dim strFile As String

'Dim MyBinary As String


strFile = &quot;D:\file.exe&quot;

Open strFile For Binary Access Write As #1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top