Reputation: 663
The Excel constant "True" evaluates to True and the constant "vbTrue" evaluates to -1. I've always treated these as interchangeable in VBA code, but it's not so. One place where these two constants produce different results is in setting CheckBoxes. Setting the CheckBox.value to True produces the expected result, but setting it to vbTrue leaves the CheckBox in a TripleState.
Sub setCkBox1()
CheckBox1.TripleState = False
CheckBox1.Value = vbTrue '<<<< the check mark is dimmed to show TripleState is True
Debug.Print CheckBox1.TripleState: Stop '<<<< even though it won't admit it
CheckBox1.Value = True '<<<< check mark is not dimmed
End Sub
So my question is, where else in VBA are these two constants not interchangeable?
Upvotes: 2
Views: 1284
Reputation: 56755
True
is a Boolean, vbTrue
is a Long. They are not interchangeable anywhere that Booleans and Longs are not interchangeable.
Upvotes: 7