Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB SYNTAX QUESTION ABOUT LOGICAL OPERATOR

Posted on 2006-07-22
2
Medium Priority
?
166 Views
Last Modified: 2010-04-30
Hi,
I have another multivariable comparison.  I want to compare 4 checkboxes to 1 - both sets shouldn't be checked.  However, the script is not recognizing when a checkbox is checked.   For example, If I check STD, I get the alert message - "missing final action, check a fad box".  It should recognize this box is checked.
I would appreciate any suggestions!!  Again, I have assigned a high pt value due to urgency.  Thank you!

Code sample:

If main.STD.Checked Then
         form69 = -1
      Else
       form69 = 0
      End If

If main.SSTDR.Checked Then
         form71 = -1
      Else
       form71 = 0
      End If

If main.SSTDW.Checked Then
         form72 = -1
      Else
       form72 = 0
      End If

If main.SSTDPE.Checked Then
         form73 = -1
      Else
       form73 = 0
      End If

If main.DECL.Checked Then
         form74 = -1
      Else
       form74 = 0
      End If

If main.PPON.Checked Then
         form75 = -1
      Else
       form75 = 0
      End If

If ((form69) = -1 Or (form71) = -1 Or (form72) = -1 Or (form73) = -1) And ((form74) = -1) Then
     MsgBox ("CAN NOT CONTINUE - MUST CHOOSE BETWEEN ISSUE AND DECLINE ACTIONS - CAN'T BE BOTH")
     Exit Sub
      ElseIf ((form69) = -1 Or (form71) = -1 Or (form72) = -1 Or (form73) = -1) And ((form75) = -1) Then
     MsgBox ("CAN NOT CONTINUE - MUST CHOOSE BETWEEN ISSUE AND POSTPONE ACTIONS - CAN'T BE BOTH")
     Exit Sub
      ElseIf (Form74) = -1 And (Form75) = -1 Then
     MsgBox ("CAN NOT CONTINUE - MUST CHOOSE BETWEEN DECLINE AND POSTPONE ACTIONS - CAN'T BE BOTH")
     Exit Sub
    ElseIf ((form69) = 0 Or (form71) = 0 Or (form72) = 0 Or (form73) = 0) And ((form74) = 0 Or (form75) = 0)Then
     MsgBox ("CAN NOT CONTINUE - MISSING FINAL ACTION DECISION - PLEASE CHECK FAD BOX")
     Exit Sub
      Else
      If main.STD.Checked Then
         form69 = -1
      Else
       form69 = 0
      End If
      If main.SSTDR.Checked Then
         form71 = -1
      Else
       form71 = 0
      End If
      If main.SSTDW.Checked Then
         form72 = -1
      Else
       form72 = 0
      End If
      If main.SSTDPE.Checked Then
         form73 = -1
      Else
       form73 = 0
      End If
      If main.DECL.Checked Then
         form74 = -1
      Else
       form74 = 0
      End If
      If main.PPON.Checked Then
         form75 = -1
      Else
       form75 = 0
      End If
  End If
0
Comment
Question by:MoJeaux39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 17160588
you have to compare against the constant vbChecked (resp vbUnchecked):
If main.STD.Checked = vbChecked Then

0
 

Author Comment

by:MoJeaux39
ID: 17160612
Yes, but setting it's value to -1 or 0 accomplish the same thing?  It's the

ElseIf ((form69) = 0 Or (form71) = 0 Or (form72) = 0 Or (form73) = 0) And ((form74) = 0 Or (form75) = 0)Then
     MsgBox ("CAN NOT CONTINUE - MISSING FINAL ACTION DECISION - PLEASE CHECK FAD BOX")
     Exit Sub
      Else

statement that doesn't recognize the value of form69, right?  

Thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question