?
Solved

Automatic Triple State Checkbox

Posted on 1998-09-15
7
Medium Priority
?
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 150 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

770 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