🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

c# clearing images

Started by
53 comments, last by phil67rpg 5 years, 2 months ago
On 4/5/2019 at 4:21 AM, phil67rpg said:

I have done pong and breakout already.

I think you made them a few years ago. Right? It is time to refresh your knowledge. Now you have better skills. You can make them more quickly and better.

We have saying Russian: "Повторение - мать учения". I found English equivalents in the Internet: "Repetition is the mother of learning".

Advertisement

well I have done a calculator program using windows forms, what should I do next?

11 hours ago, phil67rpg said:

well I have done a calculator program using windows forms, what should I do next?

Do not hurry up. I am sure that you can improve your calculator. You can take more experience than you think. Show the code of your calculator. You can apply new knowledges to your calculator. These knowledges you can apply when you will write another applications. Do not stop to improve your old application. Your applications can draw up with your knowledges. Your knowledges become your skills that you will use everywhere.

I just want to know what  to do next?

40 minutes ago, phil67rpg said:

I just want to know what  to do next?

Post your calculator code for review.  Best way to stop bad habits is to have your code reviewed by senior eyes and listen to the recommendations.

 

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

ok here is my code


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp5
{
    public partial class Form1 : Form
    {
        private string sValue = "";
        private string sOper = "";
        
        public Form1()
        {
            InitializeComponent();
        }

        private void button0_Click(object sender, EventArgs e)
        {
            textBox1.Text += button0.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text += button1.Text;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text += button2.Text;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text += button3.Text;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.Text += button4.Text;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Text += button5.Text;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            textBox1.Text += button6.Text;
        }

        private void button7_Click(object sender, EventArgs e)
        {
            textBox1.Text += button7.Text;
        }

        private void button8_Click(object sender, EventArgs e)
        {
            textBox1.Text += button8.Text;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            textBox1.Text += button9.Text;
        }

        private void button13_Click(object sender, EventArgs e)
        {
            sValue = textBox1.Text;
            textBox1.ResetText();
            sOper = button13.Text;
        }

        private void button14_Click(object sender, EventArgs e)
        {
            sValue = textBox1.Text;
            textBox1.ResetText();
            sOper = button14.Text;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            sValue = textBox1.Text;
            textBox1.ResetText();
            sOper = button15.Text;
        }

        private void button16_Click(object sender, EventArgs e)
        {
            sValue = textBox1.Text;
            textBox1.ResetText();
            sOper = button16.Text;
        }

        private void button12_Click(object sender, EventArgs e)
        {
            float Result = 0;

            switch (sOper)
            {
                case "+":
                    Result = float.Parse(sValue) + float.Parse(textBox1.Text);
                    break;
                case "-":
                    Result = float.Parse(sValue) - float.Parse(textBox1.Text);
                    break;
                case "*":
                    Result = float.Parse(sValue) * float.Parse(textBox1.Text);
                    break;
                case "/":
                    Result = float.Parse(sValue) / float.Parse(textBox1.Text);
                    break;
            }
                    textBox1.ResetText();
                    textBox1.Text = Convert.ToString(Result);
        }
    }
}

 

Looks simple but appears to get the job done. Good to see you got a project doing what you wanted. Nicely done, Phil.

For the next step...

From what I can see, your calculator will add, subtract, multiply, or divide two values just fine. I want to do three. On your calculator, I want to be able to use the keys to enter 4+5+6= and get the result. I recommend that is the next thing for you to try.

Sounds like a good choice.

(edit)

Oh by the way, the various functions for your buttons you have could be named better. I know when creating lots of buttons or controls on a form it's easy to forget about naming everything but it will help in the long run.

well I have decided to work on a memory game using c# and windows forms and pictureboxes , do  you happen to know where I can find images for my game?

16 minutes ago, phil67rpg said:

using c# and windows forms and pictureboxes

Why do you not use Unity? Unity supports C# very well. You can make standalone executables for different operating systems by a few mouse clicks. The Memory Game is described in this book: Unity in Action, Multiplatform game development in C#, Second Edition

This topic is closed to new replies.

Advertisement