热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

VBA:IsEmpty是否需要与布尔值进行比较?-VBA:DoesIsEmptyrequirecomparisiontobooleanvalue?

Imconfus.Whichtwoformsarecorrect?我很困惑。哪两种形式是正确的?IfIsEmpty(Cells(i,j))ThenMsgBox(This

I'm confus. Which two forms are correct?

我很困惑。哪两种形式是正确的?

If IsEmpty(Cells(i, j)) Then
MsgBox ("This cell is empty!")
End If

If Not IsEmpty(Cells(i, j)) Then
MsgBox ("This cell contains something!")
End If

...or:

If IsEmpty(Cells(i, j)) = True Then
MsgBox ("This cell is empty!")
End If

If IsEmpty(Cells(i, j)) = False Then
MsgBox ("This cell contains something!")
End If

Basically, do I need to compare the IsEmpty function to a boolean value?

基本上,我需要将IsEmpty函数与布尔值进行比较吗?

2 个解决方案

#1


2  

The IsEmpty function returns a boolean value, so your first examples are fine. Plus, I find them easier/simpler to read.

IsEmpty函数返回一个布尔值,所以你的第一个例子很好。另外,我发现它们更容易/更容易阅读。

#2


1  

Normally both should work. Have you tried them?

通常两者都应该有效。你试过吗?


推荐阅读
author-avatar
少年tyrty
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有