Understanding Check Boxes

Level:
Level1

Written By TheVBProgramer.

The checkbox acts as a "toggle" control: if it's on, clicking it turns it off; if it's off, clicking it turns it on. Unlike the option button, the operation of each checkbox on a form or frame is independent of all other checkboxes; changing the status of one does not affect other checkboxes.

 

The program can read or set the status of a checkbox with the Value property (which is the default property of the checkbox). The Value property of a checkbox is of the Integer type. A value of 0 means "off", a value of 1 means "on". You can use the VB constants vbUnchecked or vbChecked for 0 or 1, respectively.

 

Following is a checkbox demo. The form contains 6 checkboxes within a frame, named chkHobby1, chkHobby2, … chkHobby6. The form also contains a command button called cmdOK and a label called lblInfo. This is the form at design time:

 

 

 

The code behind the OK button is:

 

Private Sub cmdOK_Click()

 

Dim strInfo As String

strInfo = "Items selected:"

If chkHobby1 = vbChecked Then strInfo = strInfo & " aerobics"

If chkHobby2 = vbChecked Then strInfo = strInfo & " reading"

If chkHobby3 = vbChecked Then strInfo = strInfo & " travel"

If chkHobby4 = vbChecked Then strInfo = strInfo & " movies"

If chkHobby5 = vbChecked Then strInfo = strInfo & " computers"

If chkHobby6 = vbChecked Then strInfo = strInfo & " sports"

lblInfo = strInfo

End Sub

 

 

Sample run:

 

 

Download the VB project code for the example above here.

If you enjoyed this post, subscribe for updates (it's free)

programming a tax form

I am trying to design a tax form. I need to provide a series of checkboxes to indicate conditions that trigger special exemptions for
head of household- 6,000
blind- 10,000
over 65-5,000
etc.

I need to use one function for all exemptions and taxes.
My instructor says: You should be doing the checking in a check-changed event then calling a separate function to do the subtraction.
He never went over this in class, could you give me an example of what this kind of code should look like?

how to save multiple select chekbox to ms access ?

hi,
i have 12 indexed checkbox (index 0 to 11) , how can i save multiple select checkbox results to ms access ?
my module = Global conn As ADODB.Connection
Global RsData As ADODB.Recordset
my form (General) = Sub koneksi()
Set conn = New ADODB.Connection
Set conn = New ADODB.Connection
conn.Provider = "microsoft.jet.oledb.4.0"
conn.CursorLocation = adUseClient
conn.Open App.Path & "\CustomerData.mdb"
End Sub
can anyone help me, please, by sending the solution to my email : asar895@gmail.com
I really need advise, thank you

Checkbox code using ADODC Connection

Hi, what is the code for checkbox connected in a database (ADODC CONNECTION)
Thanks

hi,do you means when checkbox

hi,do you means when checkbox checked, get value from database?

If chkBox1.value = 1 Then
adoYourAdo.Recordset.Close
adoYourAdo.Recordset.Source = "select * from yourTable "
adoYourAdo.Recordset.Open
adoYourAdo.Recordset.Requery

End If

End Sub

menggunakan Check Box pada listview di VB 6.0

Bagaimana source code untuk menggunakan check box dalam listview pada VB 6.0, yang akan digunakan untuk menghapus beberapa item didalam listview

English please....

Please be so kind to translate this message in English so we can help you!

ChrisGT7

Using checkbox in Excel Macros for opening another file

Hi,
Can anyone help me in this. I have created a sheet for consolidation and when i run the macro i want to use checkbox to get data from other files(selected files) and get that data in the consolidation file. I am finding it difficult to use the checkbox for performing such action(to get data from other file which is not open)

Please somebody help me in this.

Thanks in advance

Change the background to a different color if check box is not

I am trying to figure out what code to use to change a check box background color to red if its not checked. And also, where do I input the code, in the form or report.

Thanks

Change the background to a different color if check box is not

Using VB6 it is relatively easy to control the backcolor of a checkbox. Start a new project with a form and add one checkbox to the form. The default checkbox name 'Check1" is fine. Paste the code below into the form code window. Now checking and unchecking the checkbox will result in its backcolor alternating between buttonface and red. The 'FormActivate' code is to make sure the color is right when the program is first run no matter what the default value of the checkbox is (ie. what you set as the value on the property sheet).

Option Explicit

Private Sub Check1_Click()
'
If Check1.Value = 0 Then
Check1.BackColor = vbRed
Else
Check1.BackColor = vbButtonFace
End If
'
End Sub

Private Sub Form_Activate()
'
If Check1.Value = 0 Then
Check1.BackColor = vbRed
Else
Check1.BackColor = vbButtonFace
End If
'
End Sub

CheckBox

Please Help
I want to publish all my worksheets in a excel workbook to one pdf file
but it publish only the lat sheet(sheet4) into pdf file.

Here's my code
Private Sub CommandButton1_Click()

If Check1.Value = True Then
Sheets("Sheet1").Select
If Check1.Value = True Then
Sheets("Sheet2").Select
If Check1.Value = True Then
Sheets("Sheet3").Select
If Check1.Value = True Then
Sheets("Sheet4").Select

ChDir "C:\Output"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"c:\output\New.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True

End If

CheckBox

You have four If/Then statements that are processed in series. When the first If/Then is processed Sheet1 is selected. When the second If/Then is processed Sheet1 is released and Sheet2 is selected. This continues until the last If/Then is processed and Sheet4 is the only sheet selected. Since you aren't calling your export routine after each selection you will only export the sheet that is active at the end of the If/Then statements (Sheet4). You might be able to use 'Check1.Value = True' to call your export routine one time and then loop through exporting each sheet rather than trying to select each sheet individually with If/Then statements. Or, you could call the export routine after each If/Then statement and export the active sheet. Alternatively, you could copy and paste all four sheets to a single new sheet and export it.

check box labeled as reverse

hi, will you please help me.. 1.I had 1 checkbox labeled as reverse..
2.a textbox for entry number.
3.labeled which will display the number...
And a cmd button ok... that where im going to put the code to display the entry number..
Will you please help me with the code,, please...

check box labeled as reverse

The following code was tested by me and it works. The Command Button is Command3, the textbox is Text1, the label is Label1, and the checkbox is chkReverse. The test for IsNumeric can be eliminated if the entries don't have to be numeric. Of course you are free to name the objects whatever you wish, just make sure to change the references in the following code to match the names you use.

Private Sub Command3_Click()
'
Dim strLabel1 As String
Dim i As Integer
Dim j As Integer
'
If Not (IsNumeric(Text1.Text)) Then
Label1.Caption = "Non-numeric entry!"
Exit Sub
End If
'
strLabel1 = Text1.Text
'
If chkReverse.Value = 1 Then
' Reverse character positions in string
For i = 0 To Len(Text1.Text) - 1
j = Len(Text1.Text) - i
Mid(strLabel1, i + 1, 1) = Mid(Text1.Text, j, 1)
Next i
'
ElseIf chkReverse.Value <> 1 Then
' Don't reverse character positions in string
'
End If
'
Label1.Caption = strLabel1
'
End Sub

Addendum

By your question I assumed you wanted a program to reverse the character positions in a string such as: "1234" becomes "4321". That is what my code does. If you want something else, please re-post your question with more info.

Checkbox selection

What should I do if I would like to have the selection of some checkboxes when the program starts from the previously job? I use VB6. Thanks.

Checkbox selection

You should store the checkbox values in the registry or in a text file and then read them in each time the program is run. There's really no way to make VB6 maintain values when it isn't running.

Hi ! I'm trying an exercise

Hi ! I'm trying an exercise out there .

Its something like i'm only allow to tick two checked boxes and after that the rest of the boxes will auto disabled and when i unticked one
of them , all the boxes are enabled again . any ideas ?

Hi ! I'm trying an exercise

For this demo I have created an array of checkboxes by putting one checkbox on the form and then copying and pasting it nine times. The checkboxes will be named Check1(0) through Check1(9). The behavior will be that all ten checkboxes are enabled until you click two of them (any two checkboxes, it doesn't matter which ones). When the second box is clicked the eight non-clicked boxes will be disabled. Clicking one of the two checkboxes and removing the checkmark will re-enable all checkboxes. The following code can be pasted in the code section of a blank form and then tested. Go ahead and click away!

Note: In 'Private Sub Check1_Click(Index As Integer)' the line 'If mChecked = 2' determines how many checkboxes must be checked before disabling the rest. So, if you want to require more or fewer checkboxes simply change the 2 to another number.

Option Explicit

Private blnChkState As Boolean
'

Private Sub Check1_Click(Index As Integer)
'
Dim mChecked As Integer
Dim i As Integer

blnChkState = False
For i = 0 To 9
If Check1(i).Value = 1 Then mChecked = mChecked + 1
If mChecked = 2 Then
blnChkState = True
Exit For
End If
Next i
'
If blnChkState Then
DisableChecks
Else
EnableChecks
End If
'
End Sub

Private Sub DisableChecks()
'
Dim i As Integer

For i = 0 To 9
If Check1(i).Value = 0 Then Check1(i).Enabled = False
Next i
'
End Sub

Private Sub EnableChecks()
'
Dim i As Integer

For i = 0 To 9
Check1(i).Enabled = True
Next i
'
End Sub

Addendum

The form you use for this demo will need to have ten checkboxes on it named Check1(0) through Check1(9). The form cannot be blank or else there would be no checkboxes on it. When I mentioned a blank form I was referring to a new project, but it could be taken the wrong way. Sorry.

10 checkboxes

I am going to use a control array of 10 checkboxes, Index from 0 to 9. The 2 first checkboxes (Index 0 and 1) will be your switches for the rest of the 8 checkboxes. Here is the code:

Private Sub Check1_Click(Index As Integer)
If Index < 2 Then
If Check1(0).Value And Check1(1).Value Then
For i = 2 To 9
Check1(i).Enabled = False
Next
ElseIf Not (Check1(0).Value And Check1(1).Value) Then
For i = 2 To 9
Check1(i).Enabled = True
Next
End If
End If
End Sub

When the 2 first checkboxes are both checked, then all the other 8 ones will be disabled. And if one of the 2 first checkboxed is unchecked, the 8 others will be enabled.

Checked and Unchecked, check boxes.

Hi!

I suggest that instead of using two check boxes try to use option button.

Requirements:
2 option buttons (optCheckAll, optUncheckAll).
10 check boxes (or as many as you want).

Option Explicit

Private Sub SetCheckBoxesValue(ByVal status As Integer)

Dim ctl As Control

For Each ctl In Me
If TypeOf ctl Is CheckBox Then ctl.Value = status
Next

End Sub

Private Sub optCheckAll_Click()
SetCheckBoxesValue 1
End Sub

Private Sub optUncheckAll_Click()
SetCheckBoxesValue 0
End Sub

Best regards,
tobz

help to solve this!!

i need to add the check box values into the fairpoint spread, and to display the highlighted row in respective fields...please do figure this out!!!
thanks in advance

help to solve this!!

The reason you have no answers yet is you didn't give an explanation as to what you want. Very cryptic wording, please review your request and be specific.

checkboxes

how can i put value in checkbox1?
for example check box1=1 and i have 5 checkboxes and i want to add them. those check boxes with check will be add and the result will be on text 1

check1 = Card1
check2 = Card2
check3 = Card3
check4 = Card4
check5 = Card5

Value
check1 = 1
check2 = 2
check3 = 4
check4 = 8
check5 = 16
the answer will show in Text1

if check1 and check 2 is chosen:
Text1=3

pls reply as soon as possible :)

checkboxes

My solution to your problem is a little late coming, but it works very well. Start a new VB6 project with one form. On that form put one checkbox. Copy the checkbox and paste four times for a total of five checkboxes configured as an array of checkboxes. The checkboxes will be Check1(0) through Check1(4). Set the captions as follows: Check1(0).caption = "Card1", Check1(1).caption = "Card2", Check1(2).caption = "Card3", Check1(3).caption = "Card4", Check1(4).caption = "Card5". Add a textbox (Text1) to the form. Now paste the code below into the form code section. Run the program and start checking and unchecking the check boxes. The total will be updated in real-time in text1. When a box is checked the value will be added to the total, when a box is unchecked the value will be subtracted from the total. The total displayed will always be correct for the boxes checked.

Option Explicit

Private aryCardVals(0 To 4) As Integer
Private intCardTotals As Integer
'

Private Sub Check1_Click(Index As Integer)
'
Dim crdIndex As Integer
crdIndex = Index

Text1.Text = Str(AddValues(crdIndex))
'
End Sub

Private Function AddValues(intVal As Integer) As Integer
'
Select Case Check1(intVal).Value
Case Is = 0
intCardTotals = intCardTotals - aryCardVals(intVal)
If intCardTotals < 0 Then intCardTotals = 0
'
Case Is = 1
intCardTotals = intCardTotals + aryCardVals(intVal)
'
End Select
'
AddValues = intCardTotals
'
End Function

Private Sub Form_Load()
'
Dim i As Integer
'
For i = 0 To 4
Select Case i
Case Is = 0
aryCardVals(i) = 1
Case Is = 1
aryCardVals(i) = 2
Case Is = 2
aryCardVals(i) = 4
Case Is = 3
aryCardVals(i) = 8
Case Is = 4
aryCardVals(i) = 16
End Select
Next i
'
End Sub

checkboxes

Here's the code

Private Sub CommandButton1_Click()
Dim c As Integer

If CheckBox1.Value = True Then
c = 1
Call Add(c)
CheckBox1.Value = False
End If

If CheckBox2.Value = True Then
c = 2
Call Add(c)
CheckBox2.Value = False
End If

If CheckBox3.Value = True Then
c = 4
Call Add(c)
CheckBox3.Value = False
End If

If CheckBox4.Value = True Then
c = 8
Call Add(c)
CheckBox4.Value = False
End If

If CheckBox5.Value = True Then
c = 16
Call Add(c)
CheckBox5.Value = False
End If

End Sub

Public Function Add(z)

z = Val(TextBox1.Text) + z
TextBox1.Text = z
End Function

I did this in Visual Studio 2008

Private Sub btnSum_Click(ByVal sender As System.Object, ByVal f As System.EventArgs) Handles btnSum.Click
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim sum As Integer
If check1.Checked = True Then
a = 1
End If
If check2.Checked = True Then
b = 2
End If
If check3.Checked = True Then
c = 4
End If
If check4.Checked = True Then
d = 8
End If
If check5.Checked = True Then
e = 16
End If

sum = a + b + c + d + e
TextBox1.Text = sum

End Sub

checkboxes

how can i put value in checkbox1?
for example check box1=1 and i have 5 checkboxes and i want to add them. those check boxes with check will be add and the result will be on text 1

check1 = 1
check2 = 2
check3 = 4
check4 = 8
check5 = 16
the answer will show in Text1

if check1 and check 2 is chosen:
Text1=3

pls reply as soon as possible :)

vb 6

sir
I am using VB6 and MS Access 2007.
I want to display checkmark in datareport, from currant form .
Anybody can HELP me!!!!!

Unchecking the checkbox !

. i need a past reply . i only have limited time to finish it. ( AUGUST 30) only. :))

Unchecking the checkbox PArt II ! (VB8) please . :)

. im using inputbox by the way , when i check chkcheese... inputbox will show asking for how many quantity . when i enter 2 for example , it will mutiply to the value of my chkcheese which is 10 . and the answer will be 20 . so when i unchecked the chkcheese i want to erase its added value to the txtTamount . ??? help :))

. THANKS ALOT .

Unchecking the checkbox !

I need your help , i need the codes in check boxes , that when i unchecked the checkbox(chkcheese) which has the value of 10 for example. it will erase its value on the textbox1(txtTamount) and for an instance the txtTamount has already have 500 on it and only the (10) value of chkcheese will be remove because you unchecked it and 490 will be left in the txtTamount ?? a little complicated . ahe :)

. i will really appreciate those who r willing to heLp :)))) THANKS !!!

Unchecking the checkbox

Private Sub CheckBox1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer

If CheckBox6.Value = True Then
b = 10
a = InputBox("Enter the number of items", "SAMS PIZZA STORE")
c = a * b
TextBox1.Text = Str(c)
End If
If CheckBox6.Value = False Then
d = d - c
TextBox1.Text = Str(d)

End If
End Sub

Saving a checkbox to access database

hey ya'll would someone help me with the code & properties for saving a check box to access database?

vb6 check box

dfwhow to check box data stored for ms access.

Checkbox db connect

I hope dis'll help
firstly, u cre8 a new table with a fieldname "check" then you set its type to "boolean" not "text", den you create ur vb form and add a checkbox, a dataset, connect the dataset to d table, and the checkbox to the fieldname, run the project den i hp u get what you want.

Ask for code

I am Doing Project On Petrol Pump Management System.
IF I Checked One Value And After Clicking On Add To Resource It Should add in Our List Box,Flex Grid Controls And Comboox

Checkbox Selection

Hi to all,

I need your help in check box control. My requirement is that Check1 is selected and at the same time there is validation if the validation is true then check1 = vbchecked else vbunchecked.

I did many times, it rotating the process as endless loop that is when i am assigning check1.value=0 then again it goes to the line private sub check1_click().

So please help me in this. Its very urgent.

Thanks,
Shailaja

Checkbox Selection

Try the following code. I added another checkbox, Check2, to set the value of the Boolean variable blnValidation to True and False in order to make sure this code works. If blnValidation is True then clicking on Check1 will set its value to 1 (vbChecked). If blnValidation is False then clicking on Check1 will set its value to 0 (vbUnchecked). There won't be any cycling or endless loop with this code.

Private Sub Check1_Click()
'
If blnValidation = True Then
Check1.Value = 1
Else
Check1.Value = 0
End If
'
End Sub

Private Sub Check2_Click()
'
If Check2.Value = 1 Then
blnValidation = True
ElseIf Check2.Value = 0 Then
blnValidation = False
End If
'
End Sub

Reset Checkbox

How can I reset the value of checkbox in this form?

use Check1.value = 0

use Check1.value = 0

Modifying stored details

I have a big problem concerning my checkboxes. I am a shop program and I have set my checkbox to store price and name details of a sandwich to 2 variables. I have a string that saves the name of the sandwich and a single to store the price. Here's the code for how i've done these
chkHamSalad_Click()
sngTotal = sngTotal + 1.5
strSelection = strSelection & " Ham Salad"

I want to know how I can remove the phrase " Ham Salad" from the string without removing the
entire contents of the string as I could have details for 100 other options also saved. Any help would be greatly appreciated thankyou.

Checkbox validation

Im doing a project..there i have about 11 check boxes. I want to restrict the user from clicking more than 3 checkboxes and if the user unchecks one checkbox he/she must be able to check another one instead and if he/she unchecks 2 he/she must be able to check 2 check boxes.... and so on....can you please help...its kinda urgent.....

Checkbox validation

See my reply higher up the page. Subject line checkboxes. It is the same as what you are asking for.

Connecting a checkbox in database

Can you please tell me how to connect the value of the selected checkbox into an MS access table?Thank you

Limit number of checkbox checked

I have 10 check box and I only want five of them to be checked if they are going to check more than 5 a msg box will pop up.. plan to use it on a voting apps for the school senatorial election.

Limit number of checkbox checked

Private Sub chk_click(index As Integer)
    Dim i As Integer
    Dim c As Integer
    For i = 1 To 10
        c = c + IIf(chk(i).Value = vbChecked, 1, 0)
    Next
    Select Case c
       Case Is < 5
           For i = 1 To 10
              chk(i).Enabled = True
           Next
       Case Else
           For i = 1 To 10
              chk(i).Enabled = (chk(i).Value <> vbChecked)
           Next
    End Select
End Sub

how to view your checkbox to

how to view your checkbox to a another form

changing font styles...

how about if i want to have a menu that changes the font into bold? into italic? or even underline? can you help me... i need it As Soon As Possible...

conditional statements involving check boxes

Sir, what shuld I do in this case:

I am to make a restaurant's menu. It has the list of foods. one check box each meal. For example,

Name: chkSpaghetti
Caption: Spaghetti Php. 25.00

Name: chkBurger
Caption: Burger Php. 20.00

Name: chkDrinks
Caption: Drinks Php. 15.00

Name: cmdTotal

Name: txtTotal

that's the tools that I used, Sir.
What if I want the value of txtTotal.Text be the Value of the total of all checked orders? how and what commands should I use?

Thanks,
Yaire
(Hoping this comment will be read as soon as possible as well as answered) Thanks in advance Sir.

You will need to use if

You will need to use if statments. For example in your cmdTotal click event you will want to add this code:
dim iTotal as integer

if chkSpaghetti.Value = 1 then
    iTotal = iTotal + 25
end if

if chkBurger.Value = 1 then
    iTotal = iTotal + 20
end if
''' Do this for all of your check boxes '''

txtTotal.Text = iTotal
You might want to read the Beginners Guide on the left navigation bar it will walk you through a lot of these sort of things.

VB check box

what if id like to see the items that the user choose in a message box?what i mean is that i like to see his hobbies in a message box?

Maybe this wil help Option

Maybe this wil help

Option Explicit

Private Sub Check1_Click()
If Check1 = vbChecked Then Check2.Enabled = False
If Check1 = vbUnchecked Then Check2.Enabled = True
If Check1 = vbChecked Then Check3.Enabled = False
If Check1 = vbUnchecked Then Check3.Enabled = True
End Sub

Private Sub Check2_Click()
If Check2 = vbChecked Then Check1.Enabled = False
If Check2 = vbUnchecked Then Check1.Enabled = True
If Check2 = vbChecked Then Check3.Enabled = False
If Check2 = vbUnchecked Then Check3.Enabled = True
End Sub

Private Sub Check3_Click()
If Check3 = vbChecked Then Check1.Enabled = False
If Check3 = vbUnchecked Then Check1.Enabled = True
If Check3 = vbChecked Then Check2.Enabled = False
If Check3 = vbUnchecked Then Check2.Enabled = True
End Sub

Private Sub Command1_Click()

Dim strInfo As String

If Check1 = vbChecked Then strInfo = "waarom"
If Check2 = vbChecked Then strInfo = "daarom"
If Check3 = vbChecked Then strInfo = "dus"

Label1 = strInfo

End Sub

Image Stretched Property

What is the code when I clicked a check box then the image in the image1 is stretched and when I click it again it is stretched again?

Image Stretched Property

The following code will do what I think you asked for.

Private Sub Check1_Click()
'
If Check1.Value = 0 Then Image1.Stretch = False
If Check1.Value = 1 Then Image1.Stretch = True
'
End Sub

______________________________________________________
However, if you are looking for the image to get progressively larger with each click you would set the image control's stretch property to true so that the picture fills the image control. Command buttons would be more appropriate than check boxes in this situation. One button could have a caption of '+' and the other a caption of '-'. The following code will stretch the picture if you click the '+' button and will shrink it if you click the '-' button. Just remember to set the stretch property to true.

Private Sub cmdMinus_Click()
'
Image1.Height = Image1.Height / 1.1
Image1.Width = Image1.Width / 1.1
'
End Sub

Private Sub cmdPlus_Click()
'
Image1.Height = Image1.Height * 1.1
Image1.Width = Image1.Width * 1.1
'
End Sub

Image stretched property

What is the code when I clicked the stretched check box the image loaded in the image1 is stretched and when i clicked it again the image in image1 is stretched again.

check box

sir,
how can you pass the value of the checkboxe's control property in a program. Say to make the value of a check box be equal to 2....or grayed(disabled)

hey

what if i have 5 checkboxes.. when i select the first one, others will be disabled but selecting others excluding the first none will be disabled... what i'm asking is how to disable a checkbox???????

Solution

Think this is what you searching for.

Option Explicit

Private Sub Check1_Click()
If Check1 = vbChecked Then Check2.Enabled = False
If Check1 = vbUnchecked Then Check2.Enabled = True
If Check1 = vbChecked Then Check3.Enabled = False
If Check1 = vbUnchecked Then Check3.Enabled = True
End Sub

Private Sub Check2_Click()
If Check2 = vbChecked Then Check1.Enabled = False
If Check2 = vbUnchecked Then Check1.Enabled = True
If Check2 = vbChecked Then Check3.Enabled = False
If Check2 = vbUnchecked Then Check3.Enabled = True
End Sub

Private Sub Check3_Click()
If Check3 = vbChecked Then Check1.Enabled = False
If Check3 = vbUnchecked Then Check1.Enabled = True
If Check3 = vbChecked Then Check2.Enabled = False
If Check3 = vbUnchecked Then Check2.Enabled = True
End Sub

Private Sub Command1_Click()

Dim strInfo As String

If Check1 = vbChecked Then strInfo = "waarom"
If Check2 = vbChecked Then strInfo = "daarom"
If Check3 = vbChecked Then strInfo = "dus"

Label1 = strInfo

End Sub

Checkbox Control

What if I want to save the checkbox selections and save them for the next time the form loads?

Checkbox Control

If you want to keep your current checkbox selections while loading and unloading forms you can use a public array dimensioned for the number of check boxes you have. Code such as the following, added to each Check Box's Click event, can be used to put the settings into the array: aryChkBoxes(0)=Check1.Value, aryChkBoxes(1)=Check2.Value, etc. When the form has been unloaded and loaded back again use the following code, in the Form Load event, to retrieve the settings: Check1.Value=aryChkBoxes(0), Check2.Value=aryChkBoxes(1), etc. This will be useful for maintaining the selections during a program run but will not persist the selections if the program is ended and re-started. To keep selections between program runs you would need to store them in the registry or in a file on disk and read them in on program start-up.

soloution

if you want it disabled when thform loads:
Private Sub Form_Load()
Check5.Enabled = False
End Sub

If you want it disabled when you select check box 3:
Private Sub Check3_Click()
Check5.Enabled = False
End Sub

Hope that helps...