View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson[_2_] Chip Pearson[_2_] is offline
external usenet poster
 
Posts: 95
Default Conditional Button Enabling based on Checkbox

Just out of curiosity, why the CBool?

Force of habit. In VB6, the Value property of a CheckBox returns an
Integer, not a Boolean. I like to do the conversion to boolean myself --
self-documenting code and all that.

Just in case the TripleState property of the CheckBox is True, the better
code would be as follows:

Private Sub CheckBox1_Click()
With Me.TextBox1
If IsNull(Me.CheckBox1.Value) Then
.Enabled = False ' or True, as desired
Else
.Enabled = Me.CheckBox1.Value
End If
End With
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Hi Chip:

Just out of curiosity, why the CBool?

Regards,

Vasant.

"Chip Pearson" wrote in message
...
Todd,

Try something like the following in the user form's code module:

Private Sub CheckBox1_Click()
Me.TextBox1.Enabled = CBool(Me.CheckBox1.Value)
End Sub


"Todd uttenstine" wrote in message
...
I have CheckBox1 and TextBox1 on a UserForm. What is the
code that would enable entry into TextBox1 if CheckBox1
has a check in it?

Thank you

Todd Huttenstine