Micro Focus QTP (UFT) Forums

Full Version: If statement with multi or's
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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
Code:
If LinkName = "Fax" or  LinkName = "View"  or   LinkName = "View"   Then
'code here
End if