J
jfp
In various posts, the use of the API wrapper supplied by Ken Getz and on
the MVPS website has been recommended. This is a good function, but it
has an intrinsic error in it which can trip you up if you attempt to
build upon it. The following has been submitted to the MVPS web site re
this:
re http://www.mvps.org/access/api/api0001.htm
( Call the standard Windows File Open/Save dialog box)
The code is dangerous in its assignment of the API return value to a VB
Boolean. As written (fResult = ...) the code works since fResult is
used only in the form "If fResult Then ..." If, however, the code is
modified and some other logic using "If Not fResult then ..." is added,
it will fail. fResult actually has a value of either 0 or 1 and is
hence not a real Boolean. Apparently, VB forms the "Not" by first
inverting the value and then subtracting 1. For a genuine VB Boolean,
[0, -1] => [-1, 0] and all is well. For a "C" language style boolean
(which is what the API uses) we have [0, 1] => [-1, -2], both of which
are interpreted by VB as True. Thus, regardless of value of fResult,
the expression (Not fResult) will always be True. (You may verify this
in the immediate pane via "? CInt(fResult)" and "? CInt(Not fResult)"
The API declarations need to be changed to return an integer and that
then needs to be converted into a VB Boolean as in "bGood = (fResult <>
0)"
the MVPS website has been recommended. This is a good function, but it
has an intrinsic error in it which can trip you up if you attempt to
build upon it. The following has been submitted to the MVPS web site re
this:
re http://www.mvps.org/access/api/api0001.htm
( Call the standard Windows File Open/Save dialog box)
The code is dangerous in its assignment of the API return value to a VB
Boolean. As written (fResult = ...) the code works since fResult is
used only in the form "If fResult Then ..." If, however, the code is
modified and some other logic using "If Not fResult then ..." is added,
it will fail. fResult actually has a value of either 0 or 1 and is
hence not a real Boolean. Apparently, VB forms the "Not" by first
inverting the value and then subtracting 1. For a genuine VB Boolean,
[0, -1] => [-1, 0] and all is well. For a "C" language style boolean
(which is what the API uses) we have [0, 1] => [-1, -2], both of which
are interpreted by VB as True. Thus, regardless of value of fResult,
the expression (Not fResult) will always be True. (You may verify this
in the immediate pane via "? CInt(fResult)" and "? CInt(Not fResult)"
The API declarations need to be changed to return an integer and that
then needs to be converted into a VB Boolean as in "bGood = (fResult <>
0)"