From: Mike Williams on
"Dee Earley" <dee.earley(a)icode.co.uk> wrote in message
news:O4pplc6sKHA.1796(a)TK2MSFTNGP02.phx.gbl...

>[addressed to the OP] If you do find it, good luck.
> Putting nulls in the string may end up being used as
> part of the search pattern.

If you mean they may end up being used as part of the search pattern in the
line of code that the OP wants to change (the Instr function) then you are
quite right, they would be included in the Instr search pattern if all you
did was to replace "@driverguidetoolkit.com" in the compiled exe file with
the new string "@driverguide.com " (a shorter string padded with
either 7 spaces or 7 nulls) and the Instr function would not therefore find
a match. However, the string data in the compiled exe includes a preceeding
four byte descriptor specifying the byte length of the string. In this
specific case that descriptor would currently contain the value 46 (for the
23 characters of the original string) and if you change the string to its
new value (the shorter string padded with spaces or nulls) and also change
the contents of the descriptor from 46 to 32, representing the byte length
of the new 16 character string as you wish the VB compiled exe to see it,
then the Instr function in the compiled VB exe file will ignore the trailing
7 space or null characters and will look only for the new shorter string,
which is exactly what the OP wants it to do.

In fact you don't really need to pad the new string at all. Just overwriting
the appropriate characters of the old string with the new characters of the
shorter string would also work fine, as long as you changed the preceeding
descriptor to the value 32, although padding it with spaces does make more
sense of course if you ever need to read the exe again. If the string you
wished to replace was a substring of a much longer string of course then you
would need to look for and replace the descriptor preceeding the complete
long string (unless you were happy to allow VB to use or display the
trailling spaces), but in the case of the string coded into the Instr
function in the OP's code that does not apply. Those are the reasons why in
my response to him a few days ago I said that he would need to replace both
the string and the preceeding descriptor, which has now been done and it
works fine.

Mike