Solved

Automatic Triple State Checkbox

Posted on 1998-09-15
7
347 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:UdoG
Comment Utility
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
Comment Utility
Like I said, it ain't gonna work 'cause there's no way out once it's *GREYED*!

0
 

Author Comment

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

Accepted Solution

by:
clifABB earned 50 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now