Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IIF() Evaluates Differently Than IF?
Message
De
14/08/1997 19:19:06
Biju Varghese
M.H Alshaya Co W.L.L
Kuwait, Kuwait
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00044321
Message ID:
00044802
Vues:
28
Hi, vp_dbfname = iif(EMPTY(thisform.ctextbox1.Value), "", thisform.ctextbox1.Value) Can it be replaced with the following? vp_dbfName= thisform.ctextbox1.Value Regards? Biju > > > Ok, all together now, everyone kick me. Yes, this is what I get for > staying up too late programming. Heh, after using iif() for all this time > correctly my mind just decides to try something different for no apparent > reason. :). > > >>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform