Solved

Automatic Triple State Checkbox

Posted on 1998-09-15
7
358 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 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