Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using OR to test values

    OK, I've been trying to figure this one out for a while... I don't have my ASP reference book with me so thought someone here might be of assistance....

    I have a form with 10 checkboxes. depending on your choice, I need to have the system determine the e-mail set to send a notification.

    for example:
    choices 1 - 3 and 6-9 go to person X
    choices 1 - 6 go to person Y
    choices 5 - 7 go to person Z
    choice 10 go to all

    As you can see, there's overlap in some choices....

    I tried to do this:

    Mailblock = 0

    If 10 exists then
    MailBlock = "All"
    End if

    if Mailblock <> "All" then
    if 1 exists then
    else if 2 exist then
    else if 3 exists then
    Mailblock = Mailblock and "X"
    end if
    end if

    Then do some thing similar to determine if choices were selected for Y and Z -- the goal to contatenate the MailBlock var so I can test it using Select Case.

    The PROBLEM is if the first Else If statement failes, none of the rest fire. I need to use OR (or something like that) to test for any or all of the conditions, and the If test won't do that (as far as I can tell)

    I know in Javascript you can do this sort of thing, but how do you do it in VBScript? Or can you? Or am I all wet? Or is there a way to load a var in Javascript and pass it to VBScript? Ot is there a simpler solution??

    TIA
    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using OR to test values

    Here's the gist in psudo-code (based on your explanation):

    Dim selectedValue as String
    Dim personX as Boolean
    Dim personY as Boolean
    Dim personZ as Boolean
    Dim allPersons as Boolean

    If selectedValue = 1 OR selectedValue = 2 OR selectedValue = 3 OR selectedValue = 6 OR selectedValue = 7 OR selectedValue = 8 OR selectedValue = 9 Then
    personX = True
    End If

    If selectedValue = 1 OR selectedValue = 2.... OR selectedValue = 6
    personY = True
    End If

    If selectedValue = 5 OR selectedValue = 6 OR selectedValue = 7 Then
    personZ = True
    End If

    If selectedValue = 10 Then
    allPersons = True
    End If

    If personX Then
    Send to PersonX
    End If
    If personY Then
    Send to PersonY
    End IF
    If personZ Then
    Send to PersonZ
    End If
    If allPersons Then
    Send to allPersons
    End If

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using OR to test values

    ha! i was hoping you could do that -- the online tutes I saw didn't list OR as a condition in an If...Then. (Remember, this is ASP/VBScript)

    Thanks!

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Using OR to test values

    You also could use Select Case to trim down the size of your If statements, but collapsing it all into one structure requires a lot of pre-work, and changes may be harder if the conditions are really convoluted, so it probably wouldn't be any more efficient in the end. Still, to represent your example...

    for example:
    choices 1 - 3 and 6-9 go to person X
    choices 1 - 6 go to person Y
    choices 5 - 7 go to person Z
    choice 10 go to all


    Select Case var
    Case 1-3
    'Person X
    'Person Y
    Case 4
    'Person Y
    Case 5
    'Person Y
    'Person Z
    Case 6, 10
    'Person X
    'Person Y
    'Person Z
    Case 7
    'Person X
    'Person Z
    Case 8-9
    'Person X
    Case Else
    'Error code
    End Select

    Ouch. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using OR to test values

    thanks for reminding me of the sublime efficiencies available with Select Case... unfortunately, for the code I am working with I can't use the range trick. the actual select case is operating off a string variable, not a number. anyhow, the project has gotten a bit nasty in terms of maintenance so I am trying to avoid elegance if it seems obfuscative...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •