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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:12:48+00:00 2026-05-24T13:12:48+00:00

I’m creating a simple slot machine. One button for the start, and three stop

  • 0

I’m creating a simple slot machine. One button for the start, and three stop buttons on each tile of a Picturebox. My problem is every time I click each of the stop buttons, the Picturebox won’t stop.

I need help in which, if I click the stop button on a corresponding Picturebox, it will stop and the two will continue to shuffle pictures. Then if I clicked the other stop button, another will stop and so on.

Here’s what I have for now:

namespace SlotMachine
{
    class SlotMac
    {
        private Form f;
        Button btn1 = new Button(); // First stop
        Button btn2 = new Button(); // Second stop
        Button btn3 = new Button(); // Third stop
        Button btn4 = new Button(); // Start
        Timer Clock;    // Tick
        Timer Clock1;   // Tick
        Timer Clock2;   // Tick
        Int32 tick = 0;

        public SlotMac()
        {
            f = new Form();
            f.Text = "Slot Machine";
            //f.Size = new Size(800, 700);
            f.FormBorderStyle = FormBorderStyle.FixedSingle;
        }

        PictureBox[] pics = new PictureBox[7];
        PictureBox pb = new PictureBox();

        public void Launch()
        {
            int i = 0;

            Clock = new Timer();
            Clock.Interval = 1000;
            Clock.Tick += new EventHandler(Clock_Tick);

            Clock1 = new Timer();
            Clock1.Interval = 1000;
            Clock1.Tick += new EventHandler(Clock1_Tick);

            Clock2 = new Timer();
            Clock2.Interval = 1000;
            Clock2.Tick += new EventHandler(Clock2_Tick);

            int x = 50;
            for (i = 0; i < pics.Length; i++)
            {
                pics[i] = new PictureBox();
                pics[i].Image = Image.FromFile(i+".jpg");
                pics[i].SetBounds(x, 100, 100, 100);
                x += 150;
                f.Controls.Add(pics[i]);
            }

            f.SetBounds(10, 20, 500, 500);

            // STOP
            btn1.Location = new Point(50, 250);
            btn1.Height = 40;
            btn1.Width = 100;
            f.Controls.Add(btn1);
            btn1.Text = "STOP";
            this.btn1.Click += new EventHandler(this.MyButtonClick);

            // STOP
            btn2.Location = new Point(200, 250);
            btn2.Height = 40;
            btn2.Width = 100;
            btn2.Text = "STOP";
            f.Controls.Add(btn2);
            this.btn2.Click += new EventHandler(this.MyButtonClick);

            // STOP
            btn3.Location = new Point(350, 250);
            btn3.Height = 40;
            btn3.Width = 100;
            btn3.Text = "STOP";
            f.Controls.Add(btn3);
            this.btn3.Click += new EventHandler(this.MyButtonClick);

            // START
            btn4.Location = new Point(200, 370);
            btn4.Height = 40;
            btn4.Width = 100;
            btn4.Text = "START";
            f.Controls.Add(btn4);
            this.btn4.Click += new EventHandler(btn4_Click);
            f.ShowDialog();

        }

        public void Stop_Click(object sender, EventArgs e)
        {

        }

        public void Clock_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            pics[0].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[1].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[2].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[3].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[4].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[5].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[6].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
        }

        public void Clock1_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            pics[0].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[1].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[2].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[3].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[4].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[5].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[6].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
        }

        public void Clock2_Tick(object sender, EventArgs e)
        {
            tick++;
            Random r = new Random();
            pics[0].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[1].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[2].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[3].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[4].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[5].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
            pics[6].Image = Image.FromFile(r.Next(0, 6) + ".jpg");
        }

        public void MyButtonClick(object sender, EventArgs e)
        {
            // I am having troubles in this part
            if (sender == btn1)
            {
                Clock.Stop();

            }
            if (sender == btn2)
            {
                Clock1.Stop();
            }
            if (sender == btn3)
            {
                Clock2.Stop();
            }
        }

        public void btn4_Click(object sender, EventArgs e)
        {
            Clock.Start();
            Clock1.Start();
            Clock2.Start();
        }
    }
}
  • 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-24T13:12:49+00:00Added an answer on May 24, 2026 at 1:12 pm

    I think you need to create a separate PictureBox arrays for each clock. Otherwise, the PictureBox for what is getting shown will continually reflect that changes made by the other two timers.

    Basically, if they are all based on the same array, then when the other clocks change the array, it doesn’t matter if the first clock changes it or not; it still gets changed.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
Specifically, suppose I start with the string string =hello \'i am \' me And
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.