Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uncheck check box control VB6 1

Status
Not open for further replies.

marisam

Technical User
Mar 31, 2006
57
US
The following script displays the msg Open 24... when the check box is checked

Private Sub chkhours_Click()
lblhours.Caption = "Open 24 hours 7 days a week"
End Sub

How do I remove the message and display the check box as unchecked.

Thanks
 
The Check Box will either be Checked or Unchecked when you click on it depending on its current value when you click it.

Code:
Private Sub chkhours_Click()

If chk_Hours.Value = 1 Then
    lblhours.Caption = "Open 24 hours  7 days a week"
Else
    lblhours.Caption = "Closed"
End If

End Sub

 
I would use _Change, and use .Value as True.
Code:
Sub chk_Hours_Change()
If chk_Hours.Value = True Then
    lblhours.Caption = "Open 24 hours  7 days a week"
Else
    lblhours.Caption = "Closed"
End If
End Sub

Gerry
 
The Change event will allow the code to fire in the event the user uses the spacebar instead of the mouse.
 
And if the user wants to tab into the control and...use the spacebar?

Gerry
 
Or, the user presses the "Enter Key" and you set the focus to the control etc.

Our Secretaries prefer to use the enter key to move from field to field, not the mouse.
 
Thanks for all the suggestions but I used CaptainD's answer. It worked. Thanks
Private Sub chkhours_Click()

If chk_Hours.Value = 1 Then
lblhours.Caption = "Open 24 hours 7 days a week"
Else
lblhours.Caption = "Closed"
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top