“Select Case”结构以关键字“Select case”开始,以关键字“End Select”结束。“Select Case”结构中的测试表达式可以是变量、属性或者是表达式,“语句序列1”、“语句序列2”,“语句序列3”可以是数值、字符串或与要测试的其他情况相关的其他值,如果其中某个值与变量相匹配,那么该“Case”子句下的语句被执行,然...
51CTO博客已为您找到关于VBA-Select-Case的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及VBA-Select-Case问答内容。更多VBA-Select-Case相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
1).End(3).Row With regX .Global = True For j = 2 To 5 Select Case j Case 2 s = "[^\u4e00-\u9fa5]" '取汉字 Case 3 s = "\D" '取数字 Case 4 s = "[^a-zA-Z]" '取字母 ...
End Select End Sub 3.5.3 For...Next语句 Sub xingji() Dim xj As String, i As Integer For i = 1 To 4 Step 1 Select Case Cells(i, "D") Case Is < 85 xj = "不评定" Case Is < 100 xj = "一星级" Case Is < 115 xj = "二星级" Case Is < 130 xj = "三星级" Case Else ...
Case Is < 100 xj = "一星级" Case Is < 115 xj = "二星级" Case Is < 130 xj = "三星级" Case Is < 150 xj = "四星级" Case Else xj = "五星级" End Select Cells(2, "I") = xj End Sub 3、For…Next语句 语法结构: For <循环变量>=<初值>To<终值> [Step 步长值] ...
Case Is < 100 xj = "一星级" Case Is < 115 xj = "二星级" Case Is < 130 xj = "三星级" Case Is < 150 xj = "四星级" Case Else xj = "五星级" End Select Cells(2, "I") = xj End Sub 3、For…Next语句 语法结构: For <循环变量>=<初值>To<终值> [Step 步长值] ...
2、Select Case语句 Sub SayHello1() Select Case Time Case Is < 0.5 MsgBox "早上好!" Case Is > 0.75 MsgBox "晚上!" End Select End Sub Sub SayHello2() Select Case Time Case Is < 0.5 MsgBox "早上好!" Case Is > 0.75 MsgBox "晚上!" Case Else MsgBox "下午好!" End Select End Sub ...
Sub xingji()Dim xj As String, i As Integeri = 2Do While Cells(i, "H") <> ""Select Case Cells(i, "H")Case Is < 85xj = "不评定"Case Is < 100xj = "一星级"Case Is < 115xj = "二星级"Case Is < 130xj = "三星级"Case Is < 150xj = "四星级"Case Elsexj = "五星级"...
Select Case 表达式 Case Is 条件表达式 1 返回True 时执行的操作 Case Is 条件表达式 2 返回True 时执行的操作 ... Case Else 返回True 时执行的操作 End Select (4)For...Next 循环 与python 类似,VBA 支持 For 循环,但也存在些许差别。 语法结构一:若省略 step,默认步长为 1 ...
'End Select 'End Sub Sub aa() i = 1 End Exit Sub j = 1 End Sub GO TO 'GoTo line无条件地转移到过程中指定的行。 '注意 太多的 GoTo 语句,会使程序代码不容易阅读及调试。 '尽可能使用结构化控制语句(Do...Loop、For...Next、If...Then...Else、Select Case)。