Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a tristate checkbox
DescriptionThis example shows how to make a tristate checkbox in Visual Basic 6.
Keywordstristate, tri-state, checkbox
CategoriesControls
 
In the CheckBox's MouseDown event handler, update the control's Value property to loop through checked, unchecked, and gray. Call the ReleaseCapture API function so the control doesn't receive a Click event and change its own state.
 
Private Declare Function ReleaseCapture Lib "user32" () As _
    Long

Private Sub Check1_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
Static working As Boolean

    If working Then Exit Sub
    working = True

    Select Case Check1.Value
        Case Unchecked
            Check1.Value = Gray
        Case Gray
            Check1.Value = Checked
        Case Checked
            Check1.Value = Unchecked
    End Select

    working = False

    ReleaseCapture
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated