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 7513303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:08:30+00:00 2026-05-30T00:08:30+00:00

The question: Create an application that simulates rolling a pair of dice. When the

  • 0

The question: Create an application that simulates rolling a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use PictureBox controls to display the dice.

I currently have 6 picture boxes with the picture boxes named “dice1PictureBox”, “dice2PictureBox” etc, up to 6.

Here is the code I have written so far. I am completely lost at this point. I am also very new at programming, any help is greatly appreciated. Thank you in advance.

    private void rollButton_Click(object sender, EventArgs e)
    {
        int diceOne;
        int diceTwo;

        Random rand = new Random();

        diceOne = rand.Next(3);

        if (diceOne == 0)
        {
            diceOne.Visible = true;
        }
        else (diceOne == 1)
        {
            diceOne.Visible = true;
        }
         else (diceOne == 2)
        {
            diceOne.Visible = true;
        }

        diceTwo = rand.Next(4) + 6;

        if (diceOne == 3)
        {
            diceOne.Visible = true;
        }
        else (diceOne == 4)
        {
            diceOne.Visible = true;
        }
         else (diceOne == 5)
        {
            diceOne.Visible = true;
        }
    }
}

}

  • 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-30T00:08:32+00:00Added an answer on May 30, 2026 at 12:08 am

    Let’s go over the general idea here. I’m not going to even bother with how you’re doing things right now, cause it’s not going to do what you want. Period.

    All you need is two PictureBoxes, one for each die. You then have 6 images, one for each possible value. I’d suggest keeping the images in an array or perhaps an ImageList (either way, let’s call it images); it will make things much simpler.

    When you roll, for each die, you’ll say something like roll = rand.Next(6);. roll will then correspond to the index of the image in the array. You set the Image of the corresponding PictureBox to images[roll] (or images.Images[roll] if you’re using an ImageList). No need to mess with Visible; the two PictureBoxes will always be visible.

    Just be aware that when you consider the actual value of roll, it will be from 0 to 5. Add 1 to get the value people expect to see.

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

Sidebar

Related Questions

so my question is relatively simple, can I create VB6 application that references a
Another noob question from me. I'm trying to create an application that counts, and
I am trying to create an application that simulates a slot machine. Now, I
I need to create an application that should have several themes. It means that
The question: How do I create a python application that can connect and send
Sorry if this is a stupid question... I've developed an application that creates absolute
i want to create a quiz application. the questions should be randomly selected from
The fundamental question is how do I create a unit test that needs to
Using JXTA 2.6 from http://jxse.kenai.com/ I want to create application that can run multiple
I need to create an application that allows users to design forms for various

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.