如何使用包含多个变量的Select Case Statements? [英] How can I use Select Case Statements with multiple variables?

查看:119
本文介绍了如何使用包含多个变量的Select Case Statements?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来理解为什么我一直收到一条名为无效使用Null的错误消息。当我运行此代码时。


简要说明:我有5个不同机型的5个复选框(R610,R620,R630,R670,R690)。复选框在下面的子程序中用于不同的目的但是一旦被选中我想要分配模块级变量调用模型。分别对他们来说。


我有另一个复选框{check227,见下文],指出配置是否为浅坑设计。每个特定模型都有与浅坑相关的不同成本,因此我想使用基于模型的Select Case语句。如果没有选中该复选框,那么我只想结束子程序或什么都不做。如果选中,则根据模型执行选择案例。


我真的在这里伸展我的原始编程技巧,但我很确定Select Case比我输入几十个If-Then-Else语句要快。


有人可以提供一些建议吗?谢谢。


I need some help in understanding why I keep getting an error message called "invalid use of Null" when I run this code.

Brief summary: I have 5 check boxes for 5 different machine models (R610,R620, R630,R670, R690). The checkboxes serve a different purpose in the subroutines below but once selected I want to assign a Module level variable call "Model" to them respectively.

I have another checkbox {check227, see below] that designated whether the configuration is a shallow pit design. Each particular model has a different cost associated with shallow pit so I wanted to use a Select Case statement based upon the Model. If the checkbox is not checked then I just want to End the subroutine or do nothing. If it is checked, then based upon the Model do a Select Case.

I am really stretching my primitive programming skills here, but I''m pretty sure Select Case is faster than my typing out dozens of If-Then-Else statements.

Can anyone offer some advice? Thanks.


展开 | 选择 | Wrap | 行号

推荐答案

当它给出错误消息时,它突出显示了哪一行?


发布代码时请使用代码标签。按钮看起来像撤消按钮旁边的英镑符号。
When it gives the error message, what line does it highlight?

Please use code tags when posting code. The button looks like the pound sign next to the undo button.


Seth

它突出了案例陈述。特别是案例R620。
Seth
It hightlights the Case Statement. Specifically Case R620.


看起来好像R620是空的,VBA不喜欢在那里打一个Null。


你能用吗?不同的值,例如空字符串(")或某些根本不会出现在数据中的值?例如,您可以定义类似
Looks as though R620 is Null, and VBA doesn''t like hitting a Null there.

Could you use a different value, such as an empty string ("") or some value which simply won''t appear in the data? For example you could define something like
展开 | 选择 | Wrap | 行号


这篇关于如何使用包含多个变量的Select Case Statements?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆