|
-
April 12th, 2010, 10:10 AM
#1
[RESOLVED] Visual c# - same code four times, one time is enough?
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):
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......
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|