if语句中的组合框为null [英] Combobox null in if statement

查看:57
本文介绍了if语句中的组合框为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一条if语句,如果某个组合框为null,则运行其中的一部分代码(如果其中包含数据),然后运行另一部分.我写下来了:

I am trying to code an if statement where if a certain combobox is null, then it runs a certain part of code if it has data in it then it runs another. I wrote up this:

Private Sub ProjectAddSetDateAutoBtn_Click()
If ProjectAddAllDueDateAutoCmBx = Null Then
'Code1
Msgbox("ComboBox Is Null")
Else
'Code2
Msgbox("ComboBox Has Data")
End If
End Sub

我让组合框没有数据,然后它也不会运行if的第一部分中的代码或第二部分中的代码!如果我在框中输入数据,它将完美地运行if语句的第二部分.没有错误,对此我感到很困惑. ComboBox是否有自己的"Null"?这个if语句有问题吗?

I leave the combobox with no data, and then it doesn't run the code in the first part of the if or the code in the 2nd part of it either! If I enter data into the box, it runs the 2nd part of the if statement perfectly. There are no errors, I am quite stumped on this. Do ComboBoxes have their own "Null"? Is there a problem with this if statement?

推荐答案

没有东西等于Null,甚至没有Null a>.

使用 IsNull()进行检查组合框是否为Null.

Use IsNull() to check whether the combo box is Null.

'If ProjectAddAllDueDateAutoCmBx = Null Then
If IsNull(ProjectAddAllDueDateAutoCmBx) = True Then

这篇关于if语句中的组合框为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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