[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

MULTIPLE 'AND' STATEMENT IN VBSCRIPT

HI GUYS,
I need to compare 3 variables in one statement to see if they are all set to zero, if they are, alert the end user that one needs to be checked, other wise proceed with the script.  When I use more than one AND in an IF/then statement, it throws an error.  Any suggestions?  I'm assigning a high pt value because the question is urgent.  Thank you for your time!

Here's a sample of the if then statement I tried use initially which caused the error:

If (form79) = 0 And (form80) = 0 And (form81) = 0 Then
      MsgBox ("CAN NOT CONTINUE - MISSING BANK RESULTS -CHECK ONE OF THE BOXES")
      Exit Sub
      ElseIf (Form79) = -1 And (Form80) = -1 Then
      MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
      Exit Sub
      ElseIf (Form79) = -1 And (Form81) = -1 Then
      MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
      Exit Sub
      ElseIf (Form80) = -1 And (Form81) = -1 Then
      MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
      Exit Sub
      ElseIf (Form79) = -1 Then
        (Form81) = 0
        (Form80) = 0
      ElseIf (Form80) = -1 Then
        (Form79) = 0
        (Form81) = 0
      ElseIf (Form81) = -1 Then
        (Form79) = 0
        (Form80) = 0
      Else
          If main.SCHKHIT.Checked Then
               form79 = -1
               Else
               form79 = 0
               End If
           If main.SCHKNF.Checked Then
              form80 = -1
              Else
              form80 = 0
              End If
          If main.SCHKCLR.Checked Then
             form81 = -1
             Else
             form81 = 0
             End If      
 End If
0
MoJeaux39
Asked:
MoJeaux39
  • 2
  • 2
1 Solution
 
Anthony PerkinsCommented:
Try it this way:

If (form79) = 0 And (form80) = 0 And (form81) = 0 Then
     MsgBox ("CAN NOT CONTINUE - MISSING BANK RESULTS -CHECK ONE OF THE BOXES")
     Exit Sub
      ElseIf (Form79) = -1 And (Form80) = -1 Then
     MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
     Exit Sub
      ElseIf (Form79) = -1 And (Form81) = -1 Then
     MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
     Exit Sub
      ElseIf (Form80) = -1 And (Form81) = -1 Then
     MsgBox ("CAN NOT CONTINUE - RECHECK BANK RESULTS -ONLY CHECK ONE OF THE BOXES")
     Exit Sub
      ElseIf (Form79) = -1 Then
        Form81 = 0
        Form80 = 0
      ElseIf (Form80) = -1 Then
        Form79 = 0
        Form81 = 0
      ElseIf (Form81) = -1 Then
        Form79 = 0
        Form80 = 0
      Else
          If main.SCHKHIT.Checked Then
               form79 = -1
               Else
               form79 = 0
               End If
           If main.SCHKNF.Checked Then
              form80 = -1
              Else
              form80 = 0
              End If
          If main.SCHKCLR.Checked Then
             form81 = -1
             Else
             form81 = 0
             End If    
 End If

0
 
MoJeaux39Author Commented:
What did you do?  They look identical...?  lol
0
 
MoJeaux39Author Commented:
It's working!... but I'm not sure why.  I compared the two scripts and they look the same.  Thank you for your time and solution!!
0
 
Anthony PerkinsCommented:
Look more closely, compare:

      ElseIf (Form79) = -1 Then
        (Form81) = 0
        (Form80) = 0
      ElseIf (Form80) = -1 Then
        (Form79) = 0
        (Form81) = 0
      ElseIf (Form81) = -1 Then
        (Form79) = 0
        (Form80) = 0

To:

     ElseIf (Form79) = -1 Then
        Form81 = 0
        Form80 = 0
      ElseIf (Form80) = -1 Then
        Form79 = 0
        Form81 = 0
      ElseIf (Form81) = -1 Then
        Form79 = 0
        Form80 = 0
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now