小编elu*_*oad的帖子

VBA:为什么 Not 运算符会停止工作?

这让我完全不知所措。

Sub testChangeBoolean()
  Dim X As Boolean       ' default value is False
  X = True               ' X is now True
  X = Not X              ' X is back to False
End Sub
Run Code Online (Sandbox Code Playgroud)

但我试图在表格单元格(在 Word 中)中切换 .FitText 属性。.FitText 以 True 开头。

如果我将它分配给 X:

Sub testChangeBoolean()
  Dim X As Boolean                  ' again, default is False
  X = Selection.Cells(1).FitText    ' does set X to True
  X = Not X                         ' X is still True!
End Sub
Run Code Online (Sandbox Code Playgroud)

我只是不明白我做错了什么。

vba ms-word boolean-operations

41
推荐指数
3
解决办法
1876
查看次数

标签 统计

boolean-operations ×1

ms-word ×1

vba ×1