
Uploaded with ImageShack.us Can you help me ? Thank you alot!!! =) I use the Visual c# 2010 Version!:-P
Edited by Universal11, 30 October 2010 - 08:34 AM.

Edited by Universal11, 30 October 2010 - 08:34 AM.
|
|
|
if(textbox1.text != "" || textbox2.text != "") // then go on ...
Doctor said:
if(textbox1.text != "" || textbox2.text != "") // then go on ...
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 Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double val1, val2;
val1 = double.Parse(textBox1.Text);
val2 = double.Parse(textBox2.Text);
textBox3.Text = (val1 + val2).ToString();
}
private void button2_Click(object sender, EventArgs e)
{
double val1, val2;
val1 = double.Parse(textBox2.Text);
val2 = double.Parse(textBox1.Text);
textBox3.Text = (val1 - val2).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
double val1, val2;
val2 = double.Parse(textBox2.Text);
val1 = double.Parse(textBox1.Text);
textBox3.Text = (val1 * val2).ToString();
}
private void button4_Click(object sender, EventArgs e)
{
double val1, val2;
val2 = double.Parse(textBox2.Text);
val1 = double.Parse(textBox1.Text);
textBox3.Text = (val1 / val2).ToString();
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}
So the if(textbox1.text != "" || textbox2.text != "") won't help! ...I think it is exactly the opposite (textbox1.text = "" || textbox2.text = "") ...! means NOT but at my file i must write something so that if one of the textboxes is empty it won't allow me to Add/extract/divide etc...Cuz if i press add/extract/divide and so on and one of the first 2 textboxes is empty I get error.. =( Anyway I found out by myself about clearing! Thank you for answer!
Edited by Alexander, 30 October 2010 - 02:48 PM.
Fixed incorrect bbcode
Universal11 said:
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 Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.text != "" && textBox2.text != "")
{
double val1, val2;
val1 = double.Parse(textBox1.Text);
val2 = double.Parse(textBox2.Text);
textBox3.Text = (val1 + val2).ToString();
}
else MessageBox.show("Please fill in all required data!");
}
private void button2_Click(object sender, EventArgs e)
{
if(textBox1.text != "" && textBox2.text != "")
{
double val1, val2;
val1 = double.Parse(textBox2.Text);
val2 = double.Parse(textBox1.Text);
textBox3.Text = (val1 - val2).ToString();
}
else MessageBox.show("Please fill in all required data!");
}
private void button3_Click(object sender, EventArgs e)
{
if(textBox1.text != "" && textBox2.text != "")
{
double val1, val2;
val2 = double.Parse(textBox2.Text);
val1 = double.Parse(textBox1.Text);
textBox3.Text = (val1 * val2).ToString();
}
else MessageBox.show("Please fill in all required data!");
}
private void button4_Click(object sender, EventArgs e)
{
if(textBox1.text != "" && textBox2.text != "")
{
double val1, val2;
val2 = double.Parse(textBox2.Text);
val1 = double.Parse(textBox1.Text);
textBox3.Text = (val1 / val2).ToString();
}
else MessageBox.show("Please fill in all required data!");
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
}
}
Edited by Doctor, 01 November 2010 - 03:55 AM.
Change || to &&
if(textBox1.text != "" && textBox2.text != "")
{...
0 members, 1 guests, 0 anonymous users