Micro Focus QTP (UFT) Forums
If statement with multi or's - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: If statement with multi or's (/Thread-If-statement-with-multi-or-s)



If statement with multi or's - mv8167 - 06-14-2011

How do I create an If statement to check for three variables?

Code:
LinkName = LinkObj.GetROProperty("text")

DocStyles = ("Fax","View","Zip")
DocStyles = "Fax","View","Zip"
If LinkName <> DocStyles Then

If LinkName <> "Fax" or LinkName <> "View" or LinkName <>"Zip" Then

If LinkName <> ("Fax" or "View" or "Zip") Then

If LinkName <> ("Fax","View","Zip") Then

Can someone help with what the correct coding for an If statement with multiple or's.


RE: If statement with multi or's - Brian.Osborne - 06-14-2011

Rather than focusing on what you don't want it to do, focus on what you do want it to do.
Code:
LinkName = LinkObj.GetROProperty ("Text")
If LinkName = "Fax" Then
  'insert code that you want executed if it is Fax
ElseIf LinkName = "View"
  'insert code that you want executed if it is View
EsleIf LinkName = "Zip"
  'insert code that you want executed if it is Zip
Else
  'insert code that you want executed if it is none of the above
End If

If you don't care if it's Fax, View, or Zip and just want to execute code if it's none of these then try this.
Code:
LinkName = LinkObj.GetROProperty ("Text")
If LinkName <> "Fax" or LinkName <> "View" or LinkName <> "Zip" Then
  'insert code you want executed if it's none of these
End If



RE: If statement with multi or's - rajpes - 07-05-2011

Code:
If LinkName = "Fax" or  LinkName = "View"  or   LinkName = "View"   Then
'code here
End if