“选择案例”的问题

发布于 2024-09-01 03:59:10 字数 505 浏览 5 评论 0原文

我在下面写了以下部分。 调试时,我看到我输入了第一个案例,没问题。 我的问题是第二个案例 - 它没有输入并转到错误消息。

我做错了什么?

Select Case Data_Rate
  Case "1", "2", "5.5", "11", "6", "9", "12", "18", "24", "36", "48", "54"
    a = Data_Rate

    Select Case Date_Rate
      Case "1"
        b = 2
      Case "2", "5.5", "11"
        b = 1
      Case Else:
        MsgBox ("ERROR - Data_Rate")
    End Select

  Case "0", "1", "2", "3", "4", "5", "6", "7"
    a = 3
  Case Else:
    MsgBox ("ERROR - Data_Rate")
End Select

i wrote the following section below.
when debugging, i see that i enter the first Case okay.
my problem is with the second Case - it does not enter it and goes to the error messege.

what do i do wrong?

Select Case Data_Rate
  Case "1", "2", "5.5", "11", "6", "9", "12", "18", "24", "36", "48", "54"
    a = Data_Rate

    Select Case Date_Rate
      Case "1"
        b = 2
      Case "2", "5.5", "11"
        b = 1
      Case Else:
        MsgBox ("ERROR - Data_Rate")
    End Select

  Case "0", "1", "2", "3", "4", "5", "6", "7"
    a = 3
  Case Else:
    MsgBox ("ERROR - Data_Rate")
End Select

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧故 2024-09-08 03:59:13

对于像 1、2 和 6 这样的值,它总是只执行第一个 case,

我的 case 语句就像一堆 if/else if 语句。

只执行一个块,

不执行多个块

For values like 1, 2, and 6 that are in both, it will always only execute the first case

I case statement is like a bunch of if/else if statements.

Only one block is executed

Not multiple blocks

(り薆情海 2024-09-08 03:59:12

这是您上面粘贴的实际代码吗?

如果是这样,可能是因为您将“datE_rate”而不是“datA_rate”作为嵌套 Select 语句的值。

如果没有,或者即使是这样,您可能还需要区分错误消息,以便更清楚地确定是内部 Select 失败还是外部 Select 失败。

编辑:

另外,我认为您没有使用 Option Explicit。如果是的话,它会发现您错误地使用了 Date_Rate,除非您确实有这样的变量。

Is that your actual code pasted in above?

If so, it may be because you have "datE_rate" instead of "datA_rate" as the value for your nested Select statement.

If not, or even if so, you may also want to differentiate your error messages so it's clearer whether it's the inner or outer Select that is failing.

Edit:

Also, I don't think you are using Option Explicit. If you were, it would have caught your mistaken use of Date_Rate, unless you actually do have such a variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文