Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Working of if command
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01222882
Message ID:
01222888
Views:
25
>When i run these codes, only work first if, I think not read scond if
>
>
>if thisform.text1.value=="123" or Alltrim(thisform.feeuser.value)=="khubaib"
>      feeuser=thisform.feeuser.value
>  Do Form frsptc
>    thisform.release
>
>   Else
>     = Messagebox('not allowed', 32, product)
>     thisform.release
>     Return .T.
>
>
>if ALLTRIM(thisform.text1.value)=="123" or Alltrim(thisform.feeuser.value)=="abid"
>      feeuser=thisform.feeuser.value
>    Do Form frsptc
>    thisform.release
>
>   Else
>     = Messagebox('not true', 32, product)
>     thisform.release
>     Return .T.
> ENDIF
> ENDIF
when you use OR, once the first condition is true the program will not bother with looking at the second condition.
So in your code it is a bit confusing on what you want to happen. Try this:
if thisform.text1.value=="123" or Alltrim(thisform.feeuser.value)=="khubaib"
  feeuser=thisform.feeuser.value
  Do Form frsptc
  thisform.release

   Else
    if ALLTRIM(thisform.text1.value)=="123" or Alltrim(thisform.feeuser.value)=="abid"
      feeuser=thisform.feeuser.value
      Do Form frsptc
      thisform.release
    Else
     = Messagebox('not true', 32, product)
     thisform.release
     Return .T.
    Endif
ENDIF
though I think it would be better to do:
if thisform.text1.value=="123" 
 if Alltrim(thisform.feeuser.value)=="khubaib" or Alltrim(thisform.feeuser.value)=="abid"
  feeuser=thisform.feeuser.value
  Do Form frsptc
  thisform.release
 Else
     = Messagebox('not true for feeuser', 32, product)
     thisform.release
     Return .T.
 Endif
else
     = Messagebox('not true for text1 value', 32, product)
     thisform.release
     Return .T.
ENDIF
This can be streamlined a bit more also.
local cMsgText
cMsgText = " "
if thisform.text1.value=="123" 
 if Alltrim(thisform.feeuser.value)=="khubaib" or Alltrim(thisform.feeuser.value)=="abid"
  feeuser=thisform.feeuser.value
  Do Form frsptc
 Else
     cMsgText = "not true for feeuser"
 Endif
else
     cMsgText = "not true for text1 value"
ENDIF
if !empty(cMsgText)
   = Messagebox(cMsgText, 32, product)
endif
thisform.release
Return .T.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform