[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Enable Button If At Minimum One CheckBox Is Checked.

Posted on 2010-01-08
Medium Priority
Last Modified: 2012-05-08
I think the subject says it all.  I have a form with 5 CheckBoxes on it and a Button.

I need the button to be enabled if at minimum one CheckBox is checked.
If no CheckBoxes are checked out of the 5 then the Button is NOT enabled

I think that I have done this one before but can't locate the code in my library...
Question by:H-SC
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 26211641
There are soooo many ways you could do it.

If you only have 5 CheckBoxes and this isn't likely to change then you could simply hard-code it:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Enabled = False
    End Sub

    Private Sub cb_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged, CheckBox5.CheckedChanged
        Button1.Enabled = CheckBox1.Checked OrElse CheckBox2.Checked OrElse CheckBox3.Checked OrElse CheckBox1.Checked OrElse CheckBox4.Checked OrElse CheckBox5.Checked
    End Sub

End Class

Open in new window


Author Comment

ID: 26211913

This works just fine for me.  Many thank u's

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 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