devxlogo

October 23, 1999

Extract null-delimited strings

Most API function that return a string require that you pass a buffer where they can place the result as a null-terminated ANSI string (a.k.a. ASCIIZ string). The calling code

Avoid append operations with the Replace function

I find the Replace function very useful when I want to avoid too many append operations just to insert non-printable characters. For example, the following statement: MsgBox “Disk not ready.”

Count substrings with the Replace function

You can often use the Replace function in a smewhat unorthodox ways to simplify (and sometimes optimize) your code. For example, in order to count the number of occurrences of

Replace the last occurrence of a string

Here is a one-liner that replaces the last occurrence of a substring in a string. It is slightly less efficient than using the InstrRev plus a Replace statement, but at