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

  • Home
  • SEARCH
  • 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 7033289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:02:50+00:00 2026-05-28T01:02:50+00:00

I need help with the Check button. After a user adds all the 42

  • 0

I need help with the Check button. After a user adds all the 42 numbers in the textbox and enter a number from 0-9 in the “Enter number” area and clicks on the start button, next what he should do is run through the array of labels with the red label or lblCovece and he should collect the same values like the number enters before. And after he clicks on the Check button, the programme should first validate if the value that is selected with the red label is the same as the number entered. If is valid the label should turn green and than the result should appear in the label lblResultE(the result for example should be like this: if the number entered is 2, the result it is 2+2+2…)and if is not valid in the lblResultE we take out 10 points. That’s what i did by now with some help.:) thank you.

  namespace Seminarska
   {
 public partial class Form1 : Form
     {
    private Label l,l2,lblCovece,l4,lblResultE;
    private Button bUp, bRight, bLeft, bDown, bCheck,bStart, bReset;
    private TextBox txtVnes, txtGoal;
    private Label[] pole;

    public Form1()
    {
        InitializeComponent();
        l2 = new Label();
        l2.Text = " Enter one number";
        l2.Location = new Point(230, 200);
        l2.AutoSize = true;
        l4 = new Label();
        l4.Text = "Score";
        l4.Location = new Point(240, 260);
        l4.AutoSize = true;
        lblResultE = new Label();
        lblResultE.Location = new Point(350, 260);
        lblResultE.AutoSize = true;
        bLeft = new Button();
        bLeft.Location = new Point(0, 250);
        bLeft.Width=75;
        bLeft.Height = 25;
        bLeft.Text = "LEFT";
        bCheck = new Button();
        bCheck.Location = new Point(75, 250);
        bCheck.Width = 75;
        bCheck.Height = 25;
        bCheck.Text = "Check";
        bRight = new Button();
        bRight.Location = new Point(150, 250);
        bRight.Width = 75;
        bRight.Height = 25;
        bRight.Text = "RIGHT";
        bUp = new Button();
        bUp.Location = new Point(75, 220);
        bUp.Width = 75;
        bUp.Height = 25;
        bUp.Text = "UP";
        bDown = new Button();
        bDown.Location = new Point(75, 280);
        bDown.Width = 75;
        bDown.Height = 25;
        bDown.Text = "DOWN";
        bStart = new Button();
        bStart.Location = new Point(240, 165);
        bStart.Width = 75;
        bStart.Height = 25;
        bStart.Text = "START";
        bReset = new Button();
        bReset.Location = new Point(320, 165);
        bReset.Width = 75;
        bReset.Height = 25;
        bReset.Text = "RESET";
        txtVnes = new TextBox();
        txtVnes.Location = new Point(240, 10);
        txtVnes.Width = 160;
        txtVnes.Height = 130;
        txtVnes.Multiline = true;
        txtGoal = new TextBox();
        txtGoal.Width = 75;
        txtGoal.Height = 25;
        txtGoal.Location = new Point(330, 200);
        lblCovece = new Label();
        lblCovece.Location = new Point(160,165);
        lblCovece.Width = 20;
        lblCovece.Height = 20;
        lblCovece.TextAlign = ContentAlignment.MiddleCenter;
        lblCovece.Text = "O";
        lblCovece.BackColor = Color.FromArgb(255, 0, 0);
        int a = 0;
        pole = new Label[42];
        this.Controls.Add(lblCovece); 
        for (int i = 1; i <= 6; i++)
        {
            for (int j = 1; j <= 7; j++)
            {                     
                l = new Label();
                l.Name = "label" + i.ToString() + j.ToString();                    
                l.Text = "Z";
                l.Width = 20;
                l.Height = 20;
                l.TextAlign = ContentAlignment.MiddleCenter;
                l.Parent = this;                     
                l.BackColor = Color.FromArgb(100, 149, 237);                    
                l.Location = new Point(10 + (j - 1) * 25, 15 + (i - 1) * 25);
                pole[a] = l;                  
                this.Controls.Add(l);                    
                a++;  
            }
        }

        this.Width = 460;
        this.Height = 380;           
        this.Controls.Add(l2);       
        this.Controls.Add(l4);
        this.Controls.Add(lblResultE);
        this.Controls.Add(lblTimeE);            
        this.Controls.Add(bStart);
        this.Controls.Add(bReset);
        this.Controls.Add(txtGoal);
        this.Controls.Add(txtVnes);
        this.Controls.Add(bUp);
        this.Controls.Add(bLeft);
        this.Controls.Add(bRight);
        this.Controls.Add(bDown);
        this.Controls.Add(bCheck);

        bStart.Click+=new EventHandler(bStart_Click);
        bUp.Click+=new EventHandler(bUp_Click);
        bDown.Click+=new EventHandler(bDown_Click);
        bLeft.Click+=new EventHandler(bLeft_Click);
        bRight.Click+=new EventHandler(bRight_Click);
        bCheck.Click+=new EventHandler(bZemaj_Click);
        bReset.Click+=new EventHandler(bReset_Click);
    }

    private void bStart_Click(object sender, EventArgs e)
    {
        string Str = txtGoal.Text.Trim();
        int Num;
        bool isNum = int.TryParse(Str, out Num);
        if (isNum && Str.Length == 1)
        {
            string[] ts = txtVnes.Text.Split(
                       new string[] { "\r\n" },  
                       StringSplitOptions.RemoveEmptyEntries);
            int row = 0;
            for (int i = 0; i < ts.Length && row < 6; i++)
            {
                if (LineIsValid(ts[i]))
                {
                    for (int col = 0; col < 7; col++)
                    {
                        pole[row * 7 + col].Text = ts[i][2 * col].ToString();

                    }
                    row++;
                }
            }
            for (; row < 6; row++)
            {
                for (int col = 0; col < 7; col++)
                {
                    pole[row * 7 + col].Text = "Z";
                }
            }
        }
        else
        {
            MessageBox.Show("Invalid Input");

        }
    }

     private static Regex regex = new Regex(@"^(\s)*(\d ){6}\d(\s)*$");

     private static bool LineIsValid(string line)
    {
    return regex.IsMatch(line);

     }

    private void bReset_Click(object sender, EventArgs e)
    {
           txtVnes.Clear();
            string[] ts = txtVnes.Text.Split(new string[] { "\r\n" },  
            StringSplitOptions.RemoveEmptyEntries);
            int row = 0;
            for (int i = 0; i < ts.Length && row < 6; i++)
            {

                    for (int col = 0; col < 7; col++)
                    {
                        pole[row * 7 + col].Text = "Z";
                        pole[row * 7 + col].BackColor=Color.FromArgb(100, 149, 237);
                    }
                    row++;

            }


            for (; row < 6; row++)
            {
                for (int col = 0; col < 7; col++)
                {
                    pole[row * 7 + col].Text = "Z";
                    pole[row * 7 + col].BackColor = Color.FromArgb(100, 149, 237);
                }
            }

           txtGoal.Clear();
           lblCovece.Location=new Point(160,165);

    }


    private void bUp_Click(object sender, EventArgs e)
    {
         lblCovece.Location = new Point(lblCovece.Location.X, lblCovece.Location.Y -      
             25);

    }

    private void bDown_Click(object sender, EventArgs e)
    {
        lblCovece.Location = new Point(lblCovece.Location.X, lblCovece.Location.Y + 
           25);
    }

    private void bLeft_Click(object sender, EventArgs e)
    {
        lblCovece.Location = new Point(lblCovece.Location.X - 25,              
         lblCovece.Location.Y);
    }
    private void bRight_Click(object sender, EventArgs e)
    {
        lblCovece.Location = new Point(lblCovece.Location.X + 25,  
            lblCovece.Location.Y);
    }
    private void bCheck_Click(object sender, EventArgs e)
    {


    }


    private void Form1_Load(object sender, EventArgs e)
    {

    }




     }
  }
  • 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-28T01:02:51+00:00Added an answer on May 28, 2026 at 1:02 am

    Add an int score;

    private void bCheck_Click(object sender, EventArgs e)
            {
                bool found = false;
                foreach (Label l in pole)
                {
                    if (l.Location == lblCovece.Location && l.Text == txtGoal.Text)
                    {
                        l.BackColor = Color.Green;
    
                        score += int.Parse(l.Text);
                        lblResultE.Text = score.ToString();
                        found = true;
                    }
                }
                if (!found)
                {
                    score -= 10;
                    lblResultE.Text = score.ToString();
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
I need help to replace all \n (new line) caracters for in a String,
This is for a tic tac toe game. I need help making a check
I need a bit of inspiration from somewhere and hoping someone, anyone could help.
I need to seperate the checked and unchecked check box from set of check
I need some help with jQuery and stopping an asp.net button postback. If you
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,

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.