Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case statements

Status
Not open for further replies.

generaluser

Technical User
May 24, 2002
79
US
Is it possible to insert an If...Then statement inside a Select Case

For example:

Select Case variable
Case "1"
If y >= x Then
z = "4"
ElseIf y >= q Then
a = "5"
etc. etc
Case "2"
etc. etc.
 
Hi, You might try changing Select Case to something more along these lines depending on what you want to do:

Select Case txtY

Case is = "x"
z = 4

Case is >= q
a=5


End Select
 
Well,
Here is what I want to do. I have to create a score card for employees. There score depends on 2 different things. One, is what level they are (1-4). That's what I want to do the select case on. For each level there are certain ranges they can fall in. For example, 0-10 gives you a score of 1, 11-20 gives you a score of 2, etc. So should I do an If.. Then in the middle of a select case or a select case in the middle of a select case.
 
Hi!

Nesting an If-Then-Else in a Select is certainly acceptable as is nesting Select statements. The only warning I would give is to map out your logic carefully to make sure the code does exactly what you want it to do and try to stay with variable = or textbox = instead of using does not equal <> as the logic is easier to work with.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top