Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. Controlling Program Flow > Construct Select Case Statements

6.8. Construct Select Case Statements

You can execute a specific block of code based on a value by using a Select Case statement. Using a Select Case statement is similar to using ElseIf. You can use Select Case when you have different statements to execute and the statements that execute depend upon the value of a cell, variable, number, or string. For example, you can base the calculation of sales tax on the state. You can calculate a tax rate of 5 percent if the state is Texas, 8 percent if the state is Florida, and no tax for all other states. The following is the syntax for Select Case statements.

Select Case testexpression
    [Case expressionlist -n
       [statements-n]]
    [Case Else
    [elsestatements]]
End Select


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint