This script has determined that you are an ASP developer
with a intermediate level of experience.
Often when writing code, it's helpful to be able to perform
different actions based on the value of a variable. Normally
this is done with using an "If...Then...Else...End If"
statement or a "Select Case" statement. Consider however
the following situation...
You've got a form that takes years of experience doing something
as a parameter. Based on the given experience you need to
determine which group to put the user in.
Now since you've got a nice limited number of groups that
everyone should fit into one of, a Select Case would make for
the nicest looking code, but how do you do a Select Case with
a range of numbers? You certainly don't want to type
these type of conditionals:
Select Case intExperience
Case 0, 1, 2, 3, 4, 5,... 10, 11, 12
' Do Something
Case 13, 14, 15, 16, 17,... 25
' Do Something
Case 26, 27, 28, 29, 30,... 35
' Do Something
...
End Select
So we resort back to "If...Then...Else...End If"
method:
If 0 <= intExperience And intExperience <= 12 Then
' Do Something
Else
If 13 <= intExperience And intExperience <= 25 Then
' Do Something
Else
If 26 <= intExperience And intExperience <= 35 Then
' Do Something
Else
...
End If
End If
End If
That's not much better now is it? What if we miss an End If
somewhere? It get's hard to read pretty darn fast even if
you're meticulous in your whitespace usage.
Now take a look at the source to this sample... it's quite a
bit neater if I do say so myself.
So in reality, this entire sample was written in an effort
to teach you about a feature of VBScript that does nothing
except make code pretty! Those of you who know me know
that this is not out of the ordinary... I'll go to almost
any length for neat code. Is this going a little bit
overboard? Probably... but hey you're the one who
actually read it all! ;)