VBA:IsEmpty需要比较布尔值吗?

我很混乱 哪两种forms是正确的?

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 

…要么:

 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 

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

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

通常两者都应该工作。 你试过了吗?