Access 2007 vba 空

发布于 2024-12-05 09:07:46 字数 237 浏览 5 评论 0原文

我的程序不会处理以下语句:

Dim valid as Boolean
If MyComboBox.Value Is Not Null Then valid = true

为什么不呢?

如果我尝试使用停止点单步执行,程序不会继续执行下一步,但窗体会继续运行,就好像没有运行 vba 代码一样。这很烦人,因为这意味着表单仍然可以使用,就好像没有任何问题一样,但预期的行为没有发生。

My program doesn't process past this statement:

Dim valid as Boolean
If MyComboBox.Value Is Not Null Then valid = true

Why not?

If I try to step through using stop points the program does not proceed to the next step, but the form keeps running as if no vba code is being run. This is annoying because it means the form can still be used as if nothing is wrong but the intended behavior is not occuring.

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

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

发布评论

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

评论(2

狂之美人 2024-12-12 09:07:46

IS 关键字用于测试对象的状态并且您想要测试一个值。以下工作正常:

Dim Valid as Boolean

If Not IsNull(MyComboBox.Value) Then Valid = True

请参阅以下链接以获取更详细的说明:

什么都没有?空的?丢失的?空?

The IS keyword is used for testing the state of objects and you want to test a value. The following works fine:

Dim Valid as Boolean

If Not IsNull(MyComboBox.Value) Then Valid = True

See the following link for a more detailed description:

Nothing? Empty? Missing? Null?

策马西风 2024-12-12 09:07:46

以这种方式使用此函数(至少在 Excel 中)会引发错误,因为 Null AFAIK 只能用于测试对象(并且 value 属性不是对象)。

因此...如果您想在组合框中至少有一个选定值时设置 valid = TRUE,我相信我会使用

valid = CBool​​(Len(MyCombobox.Value) )

希望它有帮助......并希望我没有误解你的问题:-)

Use this function this way (at least in Excel) raises an error, because Null AFAIK can only be used to test objects (and the value property is not an object).

Therefore... if you want to set valid = TRUE when there is at least one selected value in the Combobox, I believe I'd use

valid = CBool(Len(MyCombobox.Value))

Hope it helps... and hope I haven't misunderstand your question :-)

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