Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How do I use Select Case on checkboxes in a Groupbox control?

How do I use Select Case on checkboxes in a Groupbox control?

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rashar
    wrote on last edited by
    #1

    In Vb, I would have an option or groupbox, with checkbox controls on it. I could set a value for each checkbox and then write the following code... Select Case optGroupbox1 Case 1: 'checkbox 1 'statements Case 2: 'checkbox 2 'statements End Select How would I implement the above code in vb.net? I've tried the following but vb.net does not like Case chkbox1.CheckState = CheckState.Checked call... Select Case GroupBox1.Controls Case chkbox1.CheckState = CheckState.Checked 'statements End Select Thanks in advance.

    D 1 Reply Last reply
    0
    • R Rashar

      In Vb, I would have an option or groupbox, with checkbox controls on it. I could set a value for each checkbox and then write the following code... Select Case optGroupbox1 Case 1: 'checkbox 1 'statements Case 2: 'checkbox 2 'statements End Select How would I implement the above code in vb.net? I've tried the following but vb.net does not like Case chkbox1.CheckState = CheckState.Checked call... Select Case GroupBox1.Controls Case chkbox1.CheckState = CheckState.Checked 'statements End Select Thanks in advance.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Rashar wrote:

      Select Case GroupBox1.Controls Case chkbox1.CheckState = CheckState.Checked

      VB.NET won't work like that. Since you've specified GroupBox1.Controls in the Select statement, you can only specify properties of the Controls collection, not it's contents. You'll have to enumerate the controls collection to get this to work:

      For Each gbc As Control in GroupBox1.Controls
      Select Case gbc.Name
      Case "chkbox1":
      If gbc.CheckState = CheckState.Checked Then
      ...
      End If
      End Select
      Next

      Dave Kreskowiak Microsoft MVP - Visual Basic

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups