if-statementvbscriptms-worddocvariable

In vbscript can you use two possible conditions in an if statement? (OR)


An example would be:

If filter_purchase = 0 Or "" Then
SetDocVar "filter_purchase", "0"
Else
SetDocVar "filter_purchase", CStr(filter_purchase)
End If

But I get a 'Type Mismatch'. Would there be an easier way than doing Else IFs?


Solution

  • you have to explicitly state the condition for each OR. Please see below

    If filter_purchase = 0 Or filter_purchase = "" Then
       SetDocVar "filter_purchase", "0"
    Else
       SetDocVar "filter_purchase", CStr(filter_purchase)
    End If