给定一个简单的表单,有一个多列组合框,使用下面的代码进行填充。有人知道为什么表单返回"-1 "而不是 "1 "的TRUE吗?
Private Sub UserForm_Initialize()
loadCellInfoTest
End sub
Sub loadCellInfoTest()
With cbxBreakdown
.Clear
.ColumnCount = 4
.ColumnWidths = "70,110,70,600"
'.value = "Breakdown for: " & targetFormula
'HEADERS
.AddItem "Sheet"
.List(.ListCount - 1, 1) = "Address"
.List(.ListCount - 1, 2) = "Value"
.List(.ListCount - 1, 3) = "Formula"
.AddItem "test"
.List(.ListCount - 1, 1) = "Address"
.List(.ListCount - 1, 2) = True 'THIS RETURNS -1
.List(.ListCount - 1, 3) = "Formula"
End With
End Sub
这是因为 True
是一个布尔值,可转换为 -1
.
在VBA中通过定义。
True = -1
False = 0
In formulas:
True = 1
False = 0
如果你想把它作为文本:
.List(.ListCount - 1, 2) = "True"