vba - 字符串案例的不选择案例的案例
问题描述
我试图为可以传入的每个不同的字符串组合选择不同的大小写。在这种情况下,我使用棒球位置的缩写。
为了更容易,我添加了一个名为“Position”的字符串值来进行比较。
我目前收到错误:
编译错误:没有选择案例的案例
我认为这是某种格式错误,但我无法在网上找到任何修复它的东西。
Position = "test"
Select Case Position
Case "C"
If C.DollarPerWar < Cells(i, 8).Value Then
Set C = AssignPlayer(C, CurrentPlayer)
Case "1B"
If B1.DollarPerWar < Cells(i, 8).Value Then
Set B1 = AssignPlayer(B1, CurrentPlayer)
Case "2B"
If B2.DollarPerWar < Cells(i, 8).Value Then
Set B2 = AssignPlayer(B2, CurrentPlayer)
Case "3B"
If B3.DollarPerWar < Cells(i, 8).Value Then
Set B3 = AssignPlayer(B3, CurrentPlayer)
Case "SS"
If SS.DollarPerWar < Cells(i, 8).Value Then
Set SS = AssignPlayer(SS, CurrentPlayer)
Case "LF"
If LF.DollarPerWar < Cells(i, 8).Value Then
Set LF = AssignPlayer(LF, CurrentPlayer)
Case "CF"
If CF.DollarPerWar < Cells(i, 8).Value Then
Set CF = AssignPlayer(CF, CurrentPlayer)
Case "RF"
If RF.DollarPerWar < Cells(i, 8).Value Then
Set RF = AssignPlayer(RF, CurrentPlayer)
End Select
任何帮助,将不胜感激!
解决方案
在你的 if 语句中杀死你的新行。它们应该是一行,如下所示:
If RF.DollarPerWar < Cells(i, 8).Value Then Set RF = AssignPlayer(RF, CurrentPlayer)
推荐阅读
- node.js - NodeJS Sequelize 抛出新的错误。AssertionError({ 错误连接
- login - React 路由器:登录帖子
- android - 如何在android中更改InputTextLayout的文本颜色
- pandas - 在 pandas read_gbq 中指定表的地理位置
- string - 从 string.format c# 中获取数字
- apache-spark - 在 spark rdd 上删除 hbase,Task not serializable
- c# - 为什么 HtmlElementEventArgs.ToElement 返回 null?
- php - 这个函数语法在 php 中有什么作用?
- python - 在 Django Admin 中使用外键关系同时保存两条或多条记录
- javascript - react中的`PropTypes.node`和`PropTypes.any`有什么区别?