Solved

Automatic Triple State Checkbox

Posted on 1998-09-15
7
356 Views
Last Modified: 2008-03-03
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
0
Comment
Question by:UdoG
7 Comments
 
LVL 2

Expert Comment

by:wj7ster
ID: 1434939
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.
0
 

Author Comment

by:UdoG
ID: 1434940
I knew that i can change the value per code.
I want the 3 states change automatic by clicking on the checkbox.

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1434941
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.

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:UdoG
ID: 1434942
With this code i create a newer ending loop.
Because the line check.value = x send the click event again

0
 
LVL 12

Expert Comment

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

0
 

Author Comment

by:UdoG
ID: 1434944
OK, but this won´t help me.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1434945
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

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question