Hello,

I have a visual c# problem, with four buttons that execute different things. I also have two variables that is the same in all four buttons.

For every button I declare those two variables(float var1, float var2), so I do the same code four times, I feel that one time should be enough somehow.

I have this four times in the code( I want to have it just one time):
Code:
var1;
var2;
An ideas?

All code here
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace try18
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        
        
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            var1;
            var2;
            
           code....        }

        private void button3_Click(object sender, EventArgs e)
        {

                var1;
            var2;

      code....

        }

        private void button4_Click(object sender, EventArgs e)
        {

      var1;
            var2;

       code....

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void sub_Click(object sender, EventArgs e)
        {
            
         var1;
            var2;


code......

        }
    }
}