Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:13:53+00:00 2026-05-28T03:13:53+00:00

So at present I am learning VB and I have a project in which

  • 0

So at present I am learning VB and I have a project in which I have to display a picture box based on:

Which radio box is checked

and

if a checkbox to make the picture box visible is checked. As someone who values clean, good code this is my code and it horrifies me. My question, is there some way to condense the following using cases or some other construct I don’t know in VB.net?

    If CheckBox1.Checked = False Then
        BooksPictureBox.Visible = False
        MusicPictureBox.Visible = False
        PeriodicalsPictureBox.Visible = False
        CoffeeBarPictureBox.Visible = False
    End If
    If RadioButton1.Checked And CheckBox1.Checked = True Then
        BooksPictureBox.Visible = True
        MusicPictureBox.Visible = False
        PeriodicalsPictureBox.Visible = False
        CoffeeBarPictureBox.Visible = False
    End If
    If RadioButton2.Checked And CheckBox1.Checked = True Then
        BooksPictureBox.Visible = False
        MusicPictureBox.Visible = True
        PeriodicalsPictureBox.Visible = False
        CoffeeBarPictureBox.Visible = False
    End If
    If RadioButton3.Checked And CheckBox1.Checked = True Then
        BooksPictureBox.Visible = False
        MusicPictureBox.Visible = False
        PeriodicalsPictureBox.Visible = True
        CoffeeBarPictureBox.Visible = False
    End If
    If RadioButton4.Checked And CheckBox1.Checked = True Then
        BooksPictureBox.Visible = False
        MusicPictureBox.Visible = False
        PeriodicalsPictureBox.Visible = False
        CoffeeBarPictureBox.Visible = True
    End If

Note- all the images stack on one another, and all of them start without being visible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:13:54+00:00Added an answer on May 28, 2026 at 3:13 am

    I would create a SUb that sets all picBoxes to not visible

    Private Sub setInvisible
       BooksPictureBox.Visible = False
       MusicPictureBox.Visible = False
       PeriodicalsPictureBox.Visible = False
       CoffeeBarPictureBox.Visible = False
    End sub
    

    Then another routine

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        setInvisible
        if checkbox1.checked = false then exit sub
        if radiobutton1.checked = true then bookspicturebox.visible = true
        if radiobutton2.checked = true then musicpicturebox.visible = true
    etc...
    
    End Sub
    

    Of course, an easier way would be to just have the image dynamically load based upon radio button selection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just learning Blend/Silverlight/VS2010/.net/etc. I have a simple project that resides on a
My present contract engagement is at a large E-Commerce company. Their code base which
At present I am using eclipse for JAVA project. I always wanted to use
At present we have a denormalised database. ie Name|NameID|EmployeeID|EmployeeType I'm normalising the database to
I need to present the user with a matrix of which one column is
I have to present some 'process' or 'flow' of the application at work on
I am learning Python - Beautiful Soup by trying to scrape data. I have
I have started working on a new Xcode project, a game to be exact.
I have started learning shell scripting a few days ago. My scenario is, i
I don't have much experience with statically typed languages (currently learning Scala and loving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.