Automatic Triple State Checkbox

How can i get a Automatic Triple State Checkbox in VB 5
Changing the Style with SendMessage(ChkBox.hWnd,BM_SETSTYLE,BS_AUTO3STATE,1) will not work in VB 5
Who is Participating?
clifABBConnect With a Mentor Commented:
You'll need to maintain a separate (static) value to keep track of what the checkbox should be.  Also, you'll need a way to prevent a NEL.

Here ya go:
Private Sub Check1_Click()
  Static nValue  As Integer
  Static bHereAlready As Boolean
  If bHereAlready Then Exit Sub
  bHereAlready = True
  nValue = nValue + 1
  If nValue > 2 Then nValue = 0
  Check1.Value = nValue
  bHereAlready = False
End Sub

Set the check box's 'Value' property to one of the following:

Check1.Value = vbUnchecked ' 0
Check1.Value = vbChecked   ' 1
Check1.Value = vbGrayed    ' 2

I hope this is what you want.
UdoGAuthor Commented:
I knew that i can change the value per code.
I want the 3 states change automatic by clicking on the checkbox.

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

That won't work as the CLICK event is disable when the box is greyed. If you try to do something like:

sub Check1_Click()
temp = check1.value
temp = temp + 1
check1.value = temp mod 3
end sub

It'll crap out when temp = 2 as the CLICK event stops firing.

UdoGAuthor Commented:
With this code i create a newer ending loop.
Because the line check.value = x send the click event again

Like I said, it ain't gonna work 'cause there's no way out once it's *GREYED*!

UdoGAuthor Commented:
OK, but this won´t help me.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.