I did some tinkering around, and here are my conclusions.
Fixed string variables are first initialized as null characters (chr$(0)).
When you assign a value to the variable, unassigned characters in the string become spaces (chr$(32)).
Therefore[tt]
Mid(myVar, 1, 1) = chr$(0) [/tt]
will always be true if the variable has never been assigned, and always false if it has.
Note that if the variable is explicitly assigned the value of "", the result will be all spaces, not all nulls. This creates the following interesting phenomenon:
[tt](from the debug window, with x declared as string * 10)
x = ""
? x = ""
False
[/tt]However:
[tt]? x = space(10)
True
[/tt]
So, if you want to treat a reassignment to a blank string as unassigned, you can evaluate[tt]
Mid(myVar, 1, 1) = chr$(32)
[/tt]for true or false.
Tipgiver, your trick won't work as stated if the assigned value is the full length of the string:
[tt](from the debug window, with x declared as string * 10)
x = "HelloHello"
? instr(x, " ") = 0
True
[/tt]
HTH
Bob