mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

if, and, then Help

Author Message
Renigade

  • Total Posts : 9
  • Scores: 0
  • Reward points : 0
  • Joined: 3/2/2010
  • Status: offline
if, and, then Help Wednesday, March 10, 2010 6:48 AM (permalink)
0
[Helpful answer received] / [List Solutions Only]
I have the following in my code...
 
in dictEvtCodes I have... 0, 2 , 10
in dictEvtType, I have 3, 5
 
If (NOT dictEvtCodes.Exists(Trim(objEvent.EventCode)) and NOT dictEvtType.Exists(Trim(objEvent.EventType))) Then
do something
end if
 
When this code runs, everything that has distEvtType is missing and vice versa...
 
I am looking for something that if it is NOT in BOTH Dictionaries then do something...
 
Anyone got an answer for me Please???
 
Thanks
#1
    dm_4ever

    • Total Posts : 3673
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    Re:if, and, then Help Wednesday, March 10, 2010 6:56 AM (permalink)
    0
    That logic should be working

         Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
         dictEvtCode.Add 0, ""
         dictEvtCode.Add 2, ""
         dictEvtCode.Add 10, ""
         Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
         dictEvtType.Add 3, ""
         dictEvtType.Add 5, ""
         
         If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then
             WScript.Echo "do something"
         End If 
     

    dm_4ever

    My philosophy: K.I.S.S - Keep It Simple Stupid
    Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
    Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
    #2
      Renigade

      • Total Posts : 9
      • Scores: 0
      • Reward points : 0
      • Joined: 3/2/2010
      • Status: offline
      Re:if, and, then Help Wednesday, March 10, 2010 7:06 AM (permalink)
      0
       
              Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary") 
              dictEvtCode.Add 0, "" 
              dictEvtCode.Add 2, "" 
              dictEvtCode.Add 10, "" 
              Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary") 
              dictEvtType.Add 3, "" 
              dictEvtType.Add 5, "" 
              
              If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then 
                  WScript.Echo "do something" 
              End If 
           

       
      You would think that it does work... but using above example...
       
                   If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then 
                  WScript.Echo "do something" 
              End If      

       
      it ends...
      it will NOT echo the do something as I think it should
      #3
        dm_4ever

        • Total Posts : 3673
        • Scores: 82
        • Reward points : 0
        • Joined: 6/29/2006
        • Location: Orange County, California
        • Status: offline
        Re:if, and, then Help Wednesday, March 10, 2010 7:09 AM (permalink)
        0
        Weird...it works just fine for me on multiple machines.
        dm_4ever

        My philosophy: K.I.S.S - Keep It Simple Stupid
        Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
        Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
        #4
          Renigade

          • Total Posts : 9
          • Scores: 0
          • Reward points : 0
          • Joined: 3/2/2010
          • Status: offline
          Re:if, and, then Help Wednesday, March 10, 2010 7:29 AM (permalink)
          0
                     Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")
                        dictEvtCode.Add 0, ""
                        dictEvtCode.Add 2, ""
                        dictEvtCode.Add 10, ""
                        Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")
                        dictEvtType.Add 3, ""
                        dictEvtType.Add 5, ""
                                If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then
                            WScript.Echo "do something"
                        End If            

           
          This should also do something but it does not
          #5
            Deckyon

            • Total Posts : 45
            • Scores: 0
            • Reward points : 0
            • Joined: 8/1/2006
            • Location: Louisville, KY - USA
            • Status: offline
            Re:if, and, then Help Wednesday, March 10, 2010 7:32 AM (permalink)
            0
            Renigade


              
                Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")  
                dictEvtCode.Add 0, ""  
                dictEvtCode.Add 2, ""  
                dictEvtCode.Add 10, ""  
                Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")  
                dictEvtType.Add 3, ""  
                dictEvtType.Add 5, ""  
                 
                If Not dictEvtCode.Exists(4) And Not dictEvtType(234) Then  
                    WScript.Echo "do something"  
                End If  
             

             
            You would think that it does work... but using above example...
             
                         If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then  
                    WScript.Echo "do something"  
                End If      

             
            it ends...
            it will NOT echo the do something as I think it should


            In your example above, BOTH statements have to be met before the code will "do something".
            #6
              Deckyon

              • Total Posts : 45
              • Scores: 0
              • Reward points : 0
              • Joined: 8/1/2006
              • Location: Louisville, KY - USA
              • Status: offline
              Re:if, and, then Help Wednesday, March 10, 2010 7:35 AM (permalink)
              0
              Renigade


                         Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary")  
                        dictEvtCode.Add 0, ""  
                        dictEvtCode.Add 2, ""  
                        dictEvtCode.Add 10, ""  
                        Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary")  
                        dictEvtType.Add 3, ""  
                        dictEvtType.Add 5, ""  
                                If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then  
                            WScript.Echo "do something"  
                        End If            

               
              This should also do something but it does not


              That is because Not dictEvtCode.Exists(2) condition is not met.  2 exists.   Both conditions have to be met in order to "do something".
              <message edited by Deckyon on Wednesday, March 10, 2010 7:36 AM>
              #7
                Renigade

                • Total Posts : 9
                • Scores: 0
                • Reward points : 0
                • Joined: 3/2/2010
                • Status: offline
                Re:if, and, then Help Wednesday, March 10, 2010 8:22 AM (permalink)
                0
                Deckyon


                Renigade


                   Dim dictEvtCode : Set dictEvtCode = CreateObject("Scripting.Dictionary") 
                             dictEvtCode.Add 0, "" 
                             dictEvtCode.Add 2, "" 
                             dictEvtCode.Add 10, "" 
                             Dim dictEvtType : Set dictEvtType = CreateObject("Scripting.Dictionary") 
                             dictEvtType.Add 3, "" 
                             dictEvtType.Add 5, "" 
                                     If Not dictEvtCode.Exists(2) And Not dictEvtType(4) Then 
                                 WScript.Echo "do something" 
                             End If   


                This should also do something but it does not


                That is because Not dictEvtCode.Exists(2) condition is not met.  2 exists.   Both conditions have to be met in order to "do something".


                OK so if I don't want this... I need it to do something if ONLY one or no condition is met... if they BOTH are met I want it to do nothing.
                <message edited by Renigade on Wednesday, March 10, 2010 8:37 AM>
                #8
                  dm_4ever

                  • Total Posts : 3673
                  • Scores: 82
                  • Reward points : 0
                  • Joined: 6/29/2006
                  • Location: Orange County, California
                  • Status: offline
                  Re:if, and, then Help Wednesday, March 10, 2010 8:36 AM (permalink)
                  0
                  [This post was marked as helpful]
                  Change AND to OR then

                  @Deckyon: good catch...I did not see he had changed the values when he re-posted.
                  <message edited by dm_4ever on Wednesday, March 10, 2010 8:37 AM>
                  dm_4ever

                  My philosophy: K.I.S.S - Keep It Simple Stupid
                  Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
                  Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
                  #9
                    Deckyon

                    • Total Posts : 45
                    • Scores: 0
                    • Reward points : 0
                    • Joined: 8/1/2006
                    • Location: Louisville, KY - USA
                    • Status: offline
                    Re:if, and, then Help Wednesday, March 10, 2010 8:40 AM (permalink)
                    0
                    [This post was marked as helpful]
                    Then instead of AND, use OR.  This assumes that you want the code to do the same thing no matter which condition is met.
                    #10
                      Renigade

                      • Total Posts : 9
                      • Scores: 0
                      • Reward points : 0
                      • Joined: 3/2/2010
                      • Status: offline
                      Re:if, and, then Help Wednesday, March 10, 2010 9:03 AM (permalink)
                      0
                      Thanks ALL...
                       
                      BIG STUPID here...
                       
                      I just didn't think that the OR would do what I wanted so I didn't try it
                      #11

                        Online Bookmarks Sharing: Share/Bookmark

                        Jump to:

                        Current active users

                        There are 0 members and 1 guests.

                        Icon Legend and Permission

                        • New Messages
                        • No New Messages
                        • Hot Topic w/ New Messages
                        • Hot Topic w/o New Messages
                        • Locked w/ New Messages
                        • Locked w/o New Messages
                        • Read Message
                        • Post New Thread
                        • Reply to message
                        • Post New Poll
                        • Submit Vote
                        • Post reward post
                        • Delete my own posts
                        • Delete my own threads
                        • Rate post

                        2000-2012 ASPPlayground.NET Forum Version 3.8
                        mbt shoes www.wileywilson.com