编程中的选择结构与交互方法详解
1. Select Case 语句概述
在处理多分支选择结构时,若有众多路径可供选择,使用 Select Case 语句来编写选择结构往往比使用多个 If…Then…Else 语句更简单明了。以下是 Select Case 语句的语法及示例:
1.1 语法
Select Case selectorExpression
Case expressionList1
instructions for the first Case
[Case expressionList2
instructions for the second Case]
[Case expressionListN
instructions for the Nth Case]
[Case Else
instructions for when the selectorExpression does not match any of the
expressionLists]
End Select
1.2 示例
Select Case code
Case 1, 2
priceLabel.Text = "$15"
Case 3
priceLabel.Text = "$25"
Case 4
p
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



