Solved

Using Case Logic

Posted on 2006-10-22
4
266 Views
Last Modified: 2008-01-09
I have an ASP app that uses a access DB and I would like to use case logic to control what is displayed in a drop down.

in my record the players Grade and Sex are known in those names and those two should control the Team field.

For example if Grade = 7 or 8 and Sex = Girl then Teams drop down should have the following
      (wildcats, shock, fever, mystics)

If grade = 8 and Sex = Boy then teams = another set of teams

I would have about 10 combinations of Grade and Sex.

This is for a youth non-profit bball league

Thanks
0
Comment
Question by:pinkstonm
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
hongjun earned 125 total points
ID: 17783951
since you are trying to do a OR on 2 variables, you need If-Else If.


If Grade  7 And Sex = "Girl" Then
    '
ElseIf Grade  8 And Sex = "Body" Then
    '
End If
0
 
LVL 9

Expert Comment

by:Hypnochu
ID: 17784065
I would go for something like

Select Case Sex
      Case "Boy"
            Select Case Grade
                  Case 1
                        'do whatever for Boy grade 1
                  Case 2
                        'do whatever for Boy grade 2
                  
                  '...etc
                  
            End Select
      Case "Girl"
            Select Case Grade
                  Case 1
                        'do whatever for Girl grade 1
                  Case 2
                        'do whatever for Girl grade 2
                  
                  '...etc
                  
            End Select      
End Select
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17784445
Hi pinkstonm,

I'd go with a modified version of Hypnochu's suggestion.  Something like this

    Select Case Sex & Grade
        Case "Boy7"
            'Do whatever for boy's in 7th grade
        Case "Boy8"
            'Do whatever for boy's in 8th grade
        Case "Girl7"
            'Do whatever for girl's in 7th grade
        Case "Girl8"
            'Do whatever for girl's in 8th grade
    End Select

Cheers!
0
 
LVL 9

Expert Comment

by:Hypnochu
ID: 17784525
>> For example if Grade = 7 or 8 and Sex = Girl then

Don't forget you can have more than one condition in each case, so:

       Case "Girl"
                        Select Case Grade
                                     Case 1
                                                      'do whatever for Girl grade 1
                                     Case 2
                                                      'do whatever for Girl grade 2
                                     Case 7,8
                                          'fill list with wildcats, shock, fever, mystics
                                     '...etc

                        End Select    
End Select

or using BlueDevilFan's suggestion

  Select Case Sex & Grade
        Case "Boy7"
            'Do whatever for boy's in 7th grade
        Case "Boy8"
            'Do whatever for boy's in 8th grade
        Case "Girl7", "Girl8"
            'fill list with wildcats, shock, fever, mystics
        ' ... etc
    End Select
   
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

827 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