什么是逻辑否定/非运算符

时间:2018-02-09 07:27:00

标签: excel vba operators negation

当excel单元格为空时,我执行一段用Visual Basic for Applications(VBA)编写的代码。到目前为止,我已经在下面的代码中写了:

Public Sub BindTitles(ByVal cell As Range)
    If IsEmpty(cell.Value) Then
        Application.EnableEvents = False
        'other code
    End If
End Sub

我想反转If语句中出现的逻辑条件。在C#中,我使用exclamation operator !但是当我将其放在If块中时,它会给出以下错误:

  

编译错误:

     

无效或不合格的参考

1 个答案:

答案 0 :(得分:1)

VBA中的逻辑否定!运算符为Not

If Not IsEmpty(cell.Value) Then '...