EXCEL VBA检查输入是否为空或空格 [英] EXCEL VBA Check if entry is empty or not 'space'
问题描述
注意使用 TextBox1.Value =$>检查
TextBox1
是否为空C $ C>。
Note. Check if the TextBox1
is empty is easy by using TextBox1.Value = ""
.
但问题是当用户点击空格键
, TextBox1
仍然会将其识别为一个值。在这种情况下,我的数据将显示为一个空单元格,其中有一个空格
。所以我的问题是,是否有任何方法来检查 TextBox1.value
为空,也不包括 space
是否有1个或更多
空格
?百万感谢所有。
But the problem is when the user hit the spacebar
, TextBox1
will still recognize it as a value. In such case, my data will appear as an empty cell with 1 space
inside. So my question is, is there any method to check TextBox1.value
for empty and also not consist of space
whether there are 1 or more space
? Million thanks to all.
推荐答案
一个常见的诀窍就是这样检查:
A common trick is to check like this:
trim(TextBox1.Value & vbnullstring) = vbnullstring
这将适用于空格,空字符串和真正的空值
this will work for spaces, empty strings, and genuine null values
这篇关于EXCEL VBA检查输入是否为空或空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!