General information
Category:
Coding, syntax & commands
>Here's an odd one. The following code returns two different answers, even though they should be identical:
>
>****************
>* The following code makes vp_dbfname = ""
>****************
>iif(EMPTY(thisform.ctextbox1.Value),vp_dbfname = "", ;
> vp_dbfname = thisform.ctextbox1.Value)
>
>****************
>* This code makes vp_dbfname = thisform.ctextbox1.Value
>****************
>if EMPTY(thisform.ctextbox1.Value)
> vp_dbfname=""
>else
> vp_dbfname = thisform.ctextbox1.Value
>endif
Hi Michael!
IIF() is something diiferent, than you think it.
The sintax of IIF() is:
IIF(lExpression, eExpression1, eExpression2)
In your example, you don't use expression, instead, you use a statement. (assigment) But VFP, in this case thinks, that it is an expression, and it evaluates it. VFP tests the equality.
And depending on the result, gives .T. or .F., depending on the value of vp_dbfname.
IIF is a function, which gives back either the value of the first, or the value of the second expression.
So, you should use:
vp_dbfname = iif(EMPTY(thisform.ctextbox1.Value), "", thisform.ctextbox1.Value)
Good luck!
BB
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only