This section provides a tutorial example on how to use 'Select Case' statements to select one block of statements based on the equal condition of an expected value.
To help you understand how "Select Case" statements work, I wrote the following the example, condition_case.html:
<html>
<body>
<!-- condition_case.html
- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<pre>
<script language="vbscript">
iDay = 4
Select Case iDay
Case 0
sDay = "Sunday"
sOpenHours = "closed"
Case 1, 2, 3, 4, 5
sDay = "a weekday"
sOpenHours = "open from 9:00am to 9:00pm"
Case 6
sDay = "Saturday"
sOpenHours = "open from 9:00am to 5:00pm"
Case Else
sDay = "unkown"
sOpenHours = "undefined"
End Select
document.writeln("")
document.writeln("Today is " & sDay)
document.writeln("The library is " & sOpenHours)
</script>
</pre>
</body>
</html>
Here is the output:
Today is a weekday
The library is open from 9:00am to 9:00pm
Hope you know how to use "Select Case" statements now.