I cant stop this error XD
I've made a calculator again, but as usual there are bugs. If i click calculate without any input in the TextBoxes, the program crashes. I've tried to check if there is anything in the textboxes before i do the calculation, and stop it if its not.
Here is my code.
I'd really like to know why the program crashes ^^
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MyCalculator
{
partial class Calculator : Form
{
double num1 = 0;
double num2 = 0;
string ansver = null;
#region Object instants
TabControl TabPages = new TabControl();
TabPage TabPage_SimpleCalculations = new TabPage();
TabPage TabPage_MoneyCalculations = new TabPage();
Panel Panel_BottomPanel = new Panel();
Button Button_Close = new Button();
Button Button_Calculate = new Button();
Button Button_Reset = new Button();
Button Button_About = new Button();
TextBox TextBox_SimpleCalculationsTextBox1 = new TextBox();
TextBox TextBox_SimpleCalculationsTextBox2 = new TextBox();
RadioButton RadioButton_Plus = new RadioButton();
RadioButton RadioButton_Minus = new RadioButton();
RadioButton RadioButton_Multi = new RadioButton();
RadioButton RadioButton_Divide = new RadioButton();
#endregion
public Calculator()
{
this.Text = "My Calculator";
this.Height /= 2;
this.Height += 40;
this.BackColor = Color.DarkGray;
this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
TabPages.Parent = this;
TabPages.Dock = DockStyle.Fill;
TabPages.Controls.Add(TabPage_SimpleCalculations);
TabPage_SimpleCalculations.Text = "Simple Calculations";
TabPage_SimpleCalculations.Paint += new PaintEventHandler(TabPage_SimpleCalculations_Paint);
TabPage_MoneyCalculations.Text = "Money Calculations";
TabPage_MoneyCalculations.Enabled = false;
Panel_BottomPanel.Parent = this;
Panel_BottomPanel.Dock = DockStyle.Bottom;
Panel_BottomPanel.Height = 40;
Panel_BottomPanel.BackColor = Color.DarkGray;
Button_Close.Parent = Panel_BottomPanel;
Button_Close.BackColor = Color.LightGray;
Button_Close.ForeColor = Color.DarkGray;
Button_Close.Text = "Close";
Button_Close.Location = new Point(10, 10);
Button_Close.Click += new EventHandler(Button_Close_Click);
Button_Reset.Parent = Panel_BottomPanel;
Button_Reset.BackColor = Color.LightGray;
Button_Reset.ForeColor = Color.DarkGray;
Button_Reset.Text = "Reset";
Button_Reset.Location = new Point(95, 10);
Button_Reset.Click += new EventHandler(Button_Reset_Click);
Button_About.Parent = Panel_BottomPanel;
Button_About.BackColor = Color.DarkGray;
Button_About.ForeColor = Color.LightGray;
Button_About.Text = "About";
Button_About.Location = new Point(210, 10);
Button_About.Click += new EventHandler(Button_About_Click);
TextBox_SimpleCalculationsTextBox1.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox1.Location = new Point(10, 40);
TextBox_SimpleCalculationsTextBox1.Focus();
TextBox_SimpleCalculationsTextBox2.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox2.Location = new Point(10, 70);
Button_Calculate.Parent = TabPage_SimpleCalculations;
Button_Calculate.Text = "Calculate";
Button_Calculate.Location = new Point(135, 55);
Button_Calculate.Width *= 2;
Button_Calculate.Click += new EventHandler(Button_Calculate_Click);
RadioButton_Plus.Parent = TabPage_SimpleCalculations;
RadioButton_Plus.Text = "Plus(+)";
RadioButton_Plus.Location = new Point(10, 10);
RadioButton_Plus.AutoSize = true;
RadioButton_Minus.Parent = TabPage_SimpleCalculations;
RadioButton_Minus.Text = "Minus(-)";
RadioButton_Minus.Location = new Point(80, 10);
RadioButton_Minus.AutoSize = true;
RadioButton_Multi.Parent = TabPage_SimpleCalculations;
RadioButton_Multi.Text = "Multi(*)";
RadioButton_Multi.Location = new Point(150, 10);
RadioButton_Multi.AutoSize = true;
RadioButton_Divide.Parent = TabPage_SimpleCalculations;
RadioButton_Divide.Text = "Divide(/)";
RadioButton_Divide.Location = new Point(220, 10);
RadioButton_Divide.AutoSize = true;
}
#region Events
void Button_Close_Click(object sender, EventArgs click)
{
Close();
}
void Button_Reset_Click(object sender, EventArgs click)
{
num1 = 0;
num2 = 0;
Button_Calculate.Text = "Calculate";
TextBox_SimpleCalculationsTextBox1.ResetText();
TextBox_SimpleCalculationsTextBox2.ResetText();
}
void Button_About_Click(object sender, EventArgs click)
{
AboutWindow();
}
void TabPage_SimpleCalculations_Paint(object sender, PaintEventArgs grfx)
{
Graphics Paint = grfx.Graphics;
Paint.DrawLine(Pens.LightGray, 125, 50, 125, 80);
Paint.DrawLine(Pens.LightGray, 125, 50, 100, 50);
Paint.DrawLine(Pens.LightGray, 125, 80, 100, 80);
Paint.DrawLine(Pens.LightGray, 125, 65, 140, 65);
}
void Button_Calculate_Click(object sender, EventArgs click)
{
num1 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox1.Text);
num2 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox2.Text);
if(TextBox_SimpleCalculationsTextBox1.Text == null && TextBox_SimpleCalculationsTextBox2.Text == null) {
MessageBox.Show("No input");
}
else {
if(RadioButton_Plus.Checked) {
ansver = Convert.ToString(num1 + num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Minus.Checked) {
ansver = Convert.ToString(num1 - num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Multi.Checked) {
ansver = Convert.ToString(num1 * num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Divide.Checked) {
ansver = Convert.ToString(num1 / num2);
Button_Calculate.Text = ansver;
}
if(!RadioButton_Plus.Checked && !RadioButton_Minus.Checked && !RadioButton_Multi.Checked && !RadioButton_Divide.Checked) {
MessageBox.Show("No calculation type selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion
}
}
/*
csc -t:winexe -out:"E:\My Calculator\My Calculator.exe" "E:\My Calculator\Main.cs" "E:\My Calculator\Calculator.cs"
*/
[6961 byte] By [
dahwan] at [2007-11-20 9:16:59]

# 1 Re: I cant stop this error XD
Your textbox.text isn't going to be null...
try:
if(TextBox_SimpleCalculationsTextBox1.Text.Trim() == "" && TextBox_SimpleCalculationsTextBox2.Text.Trim() == "")
# 2 Re: I cant stop this error XD
// something like this
if (TextBox_SimpleCalculationsTextBox1.Text.Length > 0)
num1 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox1.Text);
if (TextBox_SimpleCalculationsTextBox2.Text.Length > 0)
num2 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox2.Text);
Tron at 2007-11-9 11:35:11 >

# 3 Re: I cant stop this error XD
Use Double.TryParse(). It won't blow up on invalid input.
EDIT: 'TextBox_SimpleCalculationsTextBox2' is a terrible variable name ;)
If you need to prepend with TextBox, at least remove the "TextBox1" bit from the end!.
# 4 Re: I cant stop this error XD
Whatever i call my textboxes, its a terrible name in you guy's opinion -.-
None of your replies helped my program not crash. String does not contain a definition for "Lenght". It crashes even if i change from null to "". It crashed in despite of Tron's ideas and i dont know what to do with "Double.TryParse()"
^^
More comments is very welcome!
Thanks in advance
dahwan at 2007-11-9 11:37:05 >

# 5 Re: I cant stop this error XD
Never mind; It's working now thanks to you guy's help! Specially Crackersixx!
dahwan at 2007-11-9 11:38:15 >

# 6 Re: I cant stop this error XD
use the debugger and find out where it crashes! Then come back and tell us where.
Laitinen
# 7 Re: I cant stop this error XD
"TextBox_SimpleCalculationsTextBox1"
Ok, 10 points for finding the most redundant thing about that name. You guessed it, it's both appended and prepended with "TextBox". How can you not even notice that? C'mon, it ain't rocket science to give concise but descriptive names!
String does not contain a definition for "Lenght".
Use your head. If you can't figure out what's wrong with that, you shouldn't be coding...
As for complaining that none of us helped with your crash, well, you never said what the crash was. How can we help if you don't tell us what the crash is? I can't read your mind.
If you don't understand what Double.TryParse() is, then look it up on MSDN or use google! All i'm asking for here is for you to use a little common sense, it's not much!
# 8 Re: I cant stop this error XD
Most likely you have a numberformatexception which you dont handle.
try this:
try
{
num1 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox1.Text);
num2 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox1.Text);
}
catch (FormatException fe)
{
//Show an appropriate message
MessageBox.Show(fe.ToString());
}
catch (OverflowException oe)
{
//Show an appropriate message
MessageBox.Show(oe.ToString());
}
# 9 Re: I cant stop this error XD
MutantFruit, why the hell are you jumping at my throat like that?
Ok, 10 points for finding the most redundant thing about that name. You guessed it, it's both appended and prepended with "TextBox". How can you not even notice that? C'mon, it ain't rocket science to give concise but descriptive names!
That's just mean, man. U can tell me that the textbox has a bad name without getting into personal offense like that :(
Use your head. If you can't figure out what's wrong with that, you shouldn't be coding...
Why is that? Why shouldnt i do what i love just because i couldnt figure that out at the moment?
As for complaining that none of us helped with your crash, well, you never said what the crash was. How can we help if you don't tell us what the crash is? I can't read your mind.
HELLO! Now you're just lying. i didnt complain about anything, and i did in NO WAY state that none of you helped me!! You guys helped me a lot and i am greatfull. I simply stated the fact that my program is still crashing. and i DID tell you when it crashes. i told you that my program crashes when i click the calculate button without any input in the textboxes.
It is you that shouldnt be in forums, since you cant make a single reply without making me feel horrible :(
And i've figured it all out, my program is working. Thanks for your help.
Main.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MyCalculator
{
class MainClass
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Calculator());
}
}
}
Calculator.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MyCalculator
{
partial class Calculator : Form
{
int ATM = 0;
double num1 = 0;
double num2 = 0;
double num3 = 0;
string ansver = null;
#region Object instants
TabControl TabPages = new TabControl();
TabPage TabPage_SimpleCalculations = new TabPage();
TabPage TabPage_MoneyCalculations = new TabPage();
Panel Panel_BottomPanel = new Panel();
Button Button_Close = new Button();
Button Button_Calculate = new Button();
Button Button_Reset = new Button();
Button Button_About = new Button();
Button Button_Tools_CopyToClipboard = new Button();
Button Button_Tools_SquareRoot = new Button();
TextBox TextBox_SimpleCalculationsTextBox1 = new TextBox();
TextBox TextBox_SimpleCalculationsTextBox2 = new TextBox();
TextBox TextBox_SquareRoot = new TextBox();
TextBox TextBox_Template = new TextBox();
RadioButton RadioButton_Plus = new RadioButton();
RadioButton RadioButton_Minus = new RadioButton();
RadioButton RadioButton_Multi = new RadioButton();
RadioButton RadioButton_Divide = new RadioButton();
GroupBox GroupBox_Tools = new GroupBox();
#endregion
public Calculator()
{
this.Text = "My Calculator";
this.Height /= 2;
this.Height += 110;
this.BackColor = Color.DarkGray;
this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
TabPages.Parent = this;
TabPages.Dock = DockStyle.Fill;
TabPages.Controls.Add(TabPage_SimpleCalculations);
TabPages.TabStop = false;
TabPage_SimpleCalculations.Text = "Simple Calculations";
TabPage_SimpleCalculations.Paint += new PaintEventHandler(TabPage_SimpleCalculations_Paint);
TabPage_SimpleCalculations.TabStop = false;
TabPage_MoneyCalculations.Text = "Money Calculations";
TabPage_MoneyCalculations.TabStop = false;
GroupBox_Tools.Parent = TabPage_SimpleCalculations;
GroupBox_Tools.Location = new Point(10, 100);
GroupBox_Tools.Text = "Tools";
GroupBox_Tools.Size = new Size(266, 60);
Panel_BottomPanel.Parent = this;
Panel_BottomPanel.Dock = DockStyle.Bottom;
Panel_BottomPanel.Height = 40;
Panel_BottomPanel.BackColor = Color.DarkGray;
Button_About.Parent = Panel_BottomPanel;
Button_About.BackColor = Color.DarkGray;
Button_About.ForeColor = Color.White;
Button_About.Text = "About";
Button_About.Location = new Point(10, 10);
Button_About.Click += new EventHandler(Button_About_Click);
Button_About.TabStop = false;
Button_Reset.Parent = Panel_BottomPanel;
Button_Reset.BackColor = Color.LightGray;
Button_Reset.Text = "Reset";
Button_Reset.Location = new Point(125, 10);
Button_Reset.Click += new EventHandler(Button_Reset_Click);
Button_Reset.TabStop = false;
Button_Close.Parent = Panel_BottomPanel;
Button_Close.BackColor = Color.LightGray;
Button_Close.Text = "Close";
Button_Close.Location = new Point(210, 10);
Button_Close.Click += new EventHandler(Button_Close_Click);
Button_Close.TabStop = false;
Button_Calculate.Parent = TabPage_SimpleCalculations;
Button_Calculate.Text = "Calculate";
Button_Calculate.Location = new Point(135, 55);
Button_Calculate.Width *= 2;
Button_Calculate.Click += new EventHandler(Button_Calculate_Click);
Button_Calculate.TabIndex = 2;
Button_Tools_CopyToClipboard.Parent = GroupBox_Tools;
Button_Tools_CopyToClipboard.Text = "Copy result";
Button_Tools_CopyToClipboard.Location = new Point(10, 25);
Button_Tools_CopyToClipboard.Click += new EventHandler(Button_Tools_CopyToClipboard_Click);
Button_Tools_CopyToClipboard.TabStop = false;
Button_Tools_SquareRoot.Parent = GroupBox_Tools;
Button_Tools_SquareRoot.Text = "Square root";
Button_Tools_SquareRoot.Location = new Point(95, 25);
Button_Tools_SquareRoot.Click += new EventHandler(Button_Tools_SquareRoot_Click);
TextBox_SimpleCalculationsTextBox1.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox1.Location = new Point(10, 40);
TextBox_SimpleCalculationsTextBox1.TabIndex = 0;
TextBox_SimpleCalculationsTextBox1.Focus();
TextBox_SimpleCalculationsTextBox2.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox2.Location = new Point(10, 70);
TextBox_SimpleCalculationsTextBox2.TabIndex = 1;
TextBox_SquareRoot.Parent = null;
TextBox_SquareRoot.Location = new Point(10, 40);
TextBox_Template.Parent = null;
TextBox_Template.Location = new Point(10, 70);
TextBox_Template.Enabled = false;
RadioButton_Plus.Parent = TabPage_SimpleCalculations;
RadioButton_Plus.Text = "Plus(+)";
RadioButton_Plus.Location = new Point(10, 10);
RadioButton_Plus.AutoSize = true;
RadioButton_Plus.Enabled = true;
RadioButton_Minus.Parent = TabPage_SimpleCalculations;
RadioButton_Minus.Text = "Minus(-)";
RadioButton_Minus.Location = new Point(80, 10);
RadioButton_Minus.AutoSize = true;
RadioButton_Minus.Enabled = true;
RadioButton_Multi.Parent = TabPage_SimpleCalculations;
RadioButton_Multi.Text = "Multi(*)";
RadioButton_Multi.Location = new Point(150, 10);
RadioButton_Multi.AutoSize = true;
RadioButton_Multi.Enabled = true;
RadioButton_Divide.Parent = TabPage_SimpleCalculations;
RadioButton_Divide.Text = "Divide(/)";
RadioButton_Divide.Location = new Point(220, 10);
RadioButton_Divide.AutoSize = true;
RadioButton_Divide.Enabled = true;
}
#region Events
void TabPage_SimpleCalculations_Paint(object sender, PaintEventArgs grfx) // PAGE 1 PAINT
{
Graphics Paint = grfx.Graphics;
Paint.DrawLine(Pens.LightGray, 125, 50, 125, 80);
Paint.DrawLine(Pens.LightGray, 125, 50, 100, 50);
Paint.DrawLine(Pens.LightGray, 125, 80, 100, 80);
Paint.DrawLine(Pens.LightGray, 125, 65, 140, 65);
}
void Button_Close_Click(object sender, EventArgs click) //CLOSE CLICK
{
Close();
}
void Button_Reset_Click(object sender, EventArgs click) //RESET CLICK
{
Reset();
}
void Button_About_Click(object sender, EventArgs click) //ABOUT CLICK
{
AboutWindow();
}
void Button_Calculate_Click(object sender, EventArgs click) // CALCULATE CLICK
{
if(ATM == 0)
{
if(TextBox_SimpleCalculationsTextBox1.Text == "" && TextBox_SimpleCalculationsTextBox2.Text == "") {
MessageBox.Show("No input");
}
else {
num1 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox1.Text);
num2 = Convert.ToDouble(TextBox_SimpleCalculationsTextBox2.Text);
if(RadioButton_Plus.Checked) {
ansver = Convert.ToString(num1 + num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Minus.Checked) {
ansver = Convert.ToString(num1 - num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Multi.Checked) {
ansver = Convert.ToString(num1 * num2);
Button_Calculate.Text = ansver;
}
if(RadioButton_Divide.Checked) {
ansver = Convert.ToString(num1 / num2);
Button_Calculate.Text = ansver;
}
if(!RadioButton_Plus.Checked && !RadioButton_Minus.Checked && !RadioButton_Multi.Checked && !RadioButton_Divide.Checked) {
MessageBox.Show("No calculation type selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
if(ATM == 1)
{
if(TextBox_SquareRoot.Text == "") {
MessageBox.Show("No input");
}
else{
num3 = Convert.ToDouble(TextBox_SquareRoot.Text);
SquareRoot(num3);
Button_Calculate.Text = Convert.ToString(num3);
}
}
}
void Button_Tools_CopyToClipboard_Click(object sender, EventArgs click)
{
if(Button_Calculate.Text != "Calculate") {
Clipboard.SetText(Button_Calculate.Text);
}
}
void Button_Tools_SquareRoot_Click(object sender, EventArgs click)
{
ATM = 1;
TextBox_SimpleCalculationsTextBox1.Parent = null;
TextBox_SimpleCalculationsTextBox2.Parent = null;
TextBox_SquareRoot.Parent = TabPage_SimpleCalculations;
TextBox_Template.Parent = TabPage_SimpleCalculations;
RadioButton_Plus.Enabled = false;
RadioButton_Minus.Enabled = false;
RadioButton_Multi.Enabled = false;
RadioButton_Divide.Enabled = false;
RadioButton_Plus.Checked = false;
RadioButton_Minus.Checked = false;
RadioButton_Multi.Checked = false;
RadioButton_Divide.Checked = false;
}
#endregion
}
}
/*
csc -t:winexe -out:"E:\Tomas\My Calculator\My Calculator.exe" "E:\Tomas\My Calculator\Main.cs" "E:\Tomas\My Calculator\Calculator.cs"
*/
Method_Library.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MyCalculator {
partial class Calculator {
void AboutWindow() {
MessageBox.Show("My Calculator is a freeware program made by Tomas Sandven.\n" +
"Feel free to use and spread.", "About My Calculator", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void CopyToClipBoard() {
if(Button_Calculate.Text == "Calculate") {
MessageBox.Show("No calculation made");
}
else {
Clipboard.SetText(Button_Calculate.Text);
}
}
void SquareRoot(double sqrt) {
num3 = Math.Sqrt(sqrt);
}
void Reset() {
ATM = 0;
num1 = 0;
num2 = 0;
num3 = 0;
Button_Calculate.Text = "Calculate";
TextBox_SimpleCalculationsTextBox1.ResetText();
TextBox_SimpleCalculationsTextBox2.ResetText();
RadioButton_Plus.Checked = false;
RadioButton_Minus.Checked = false;
RadioButton_Multi.Checked = false;
RadioButton_Divide.Checked = false;
TextBox_SimpleCalculationsTextBox1.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox1.Location = new Point(10, 40);
TextBox_SimpleCalculationsTextBox1.TabIndex = 0;
TextBox_SimpleCalculationsTextBox1.Focus();
TextBox_SimpleCalculationsTextBox2.Parent = TabPage_SimpleCalculations;
TextBox_SimpleCalculationsTextBox2.Location = new Point(10, 70);
TextBox_SimpleCalculationsTextBox2.TabIndex = 1;
TextBox_SquareRoot.Parent = null;
TextBox_SquareRoot.Location = new Point(10, 40);
TextBox_Template.Parent = null;
TextBox_Template.Location = new Point(10, 70);
TextBox_Template.Enabled = false;
RadioButton_Plus.Enabled = true;
RadioButton_Minus.Enabled = true;
RadioButton_Multi.Enabled = true;
RadioButton_Divide.Enabled = true;
}
}
}
I realise i've done some unnessecary twists in here, like f. inst. the Square Root calculating, but this program, like all my other programs is merely for learning and training, so i played around for a lot.
What do you think? ^^
PS. Its still W.I.P. :D
dahwan at 2007-11-9 11:42:10 >

# 10 Re: I cant stop this error XD
Why is that? Why shouldnt i do what i love just because i couldnt figure that out at the moment?
If you can't fix a simple typo of 2 letters, then i don't think you'll ever be able to handle loops, which are infinitely more complex than using intelli-sense to select Length instead of Lenght. Seriously, if you cannot figure that out, you really shouldn't be coding. Coding isn't just slapping a bunch of constructs together, it actually does require a bit of thinking. At a very very basic level, it requires you to be able to spell at a basic level.
HELLO! Now you're just lying. i didnt complain about anything, and i did in NO WAY state that none of you helped me!!
Absolutely right. I misinterpreted your statement "None of your replies helped my program not crash." to mean that you were complaining that we didn't help. My mistake.
i DID tell you when it crashes. i told you that my program crashes when i click the calculate button without any input in the textboxes.
But you didn't ever mention what the crash was. The stacktrace and exception name that you get when a program crashes are the two best ways of figuring out what has gone wrong. If you had supplied that information, people would be able to tell you the problem without the effort of having to go compile your code.
As for the bad naming of your textbox, well, i did suggest a fix for that, and it's a very valid point i raised. When you replied complaining that every name you choose is bad, well, it is. Can you not see that both appending and prepending with "TextBox" is a complete waste of time? It adds no value whatsoever but instead makes it harder to read the code due to excessive length of variable names.
# 11 Re: I cant stop this error XD
Sorry i didnt know if it was spelled Length or Lenght; I'm norwegian.
dahwan at 2007-11-9 11:44:22 >

# 12 Re: I cant stop this error XD
You're using an IDE. How could you not know...
# 13 Re: I cant stop this error XD
Hi dahwan! Nice to see some norwegians here!
I see you have fixed your code. You check if both textboxes are empty, if they are you show a message box. Have you tried your code if only one of them are empty? What happens then? Take a look at my post #9.
Lykke til!
Laitinen
# 14 Re: I cant stop this error XD
Thanks a lot! Fixed ;-)
if(TextBox_SimpleCalculationsTextBox1.Text == "" || TextBox_SimpleCalculationsTextBox2.Text == "") {
MessageBox.Show("Input error");
}
Admin: Non-English phrase removed.
My program is working better than i had expected now ;-P
dahwan at 2007-11-9 11:47:22 >

# 15 Re: I cant stop this error XD
Whatever i call my textboxes, its a terrible name in you guy's opinion Not at all dahwan. But is it really so difficult to find names that are
a) descriptive
b) not unnecessary long
You have bettered obviously as you now take names that could not been misinterpreted in the way as in your former code where you named a richtextbox simple as textbox1 and everybody was searching for your richtextbox1, because in the forum you told about richtextbox1.
But now you do it the opposit way. Your textboxname 2 times tells us that it is a textbox. You will have to find your own style in life.
But I'll try to give you an idea. A part of the name should show what sort of control it is and a part of the name should show the usage of the control in the code. So for example do I.
The name 'TextBox_SimpleCalculationsTextBox1 gives information that we have a textbox control here. It says, thta it is used in Simplecalculations, but what does that mean. ? I can see that you have two of them, one is additionally named with TextBox1 the other with TextBox2. So that all is nearly the same then just using Textbox1 and Textbox2 as we had in earlier times.
I cannot get an idea what this textboxes are ? Is one for the first number and one for a second number ? If so why not naming it like
txtBoxFirstInput, txtBoxNextInput or something like that, as I said, I have no idea why you have two inputs and whatfor. so I cannot give it proper names, which describe what the input is for. But you as the programmer know and so you should be able to give descriptive names.
Because your names are not descriptive, I cannot tell you what to use in your case. This is the test for your names. Nobody can tell you what this input is. Are both numeric, is one of them for numbers the other for the '+','-' ... signs ?
Could not be seen by that names. Thats the point of view.
None of your replies helped my program not crash. ... what to do with "Double.TryParse()"
^^ ...
This has caused Mutant_Fruit obviouly to attack you. Ok You didn't say here, we havn't helped you directly, you wanted to tell us, that the help hasn't helped, which easily could be read in a way nobody helped you. Here again remember we have had discussions about the sound of your posts and remeber one of your threads has been closed because of it.
People like me and Mutant have been on the former thread too,( I think I remember correct ). When I had read this I have read it three times then decided not to react, because it could be read in both ways.
(And BTW what means this signs ^^ in the end of the post ? I dont understand that ? Use the given smiles instead of strange signs. )
An idea to get a better response: If something doesn't help, simple write like: ' Hey guys, I have tried your suggestion but still have the same troubles. The sentence 'None of your replies helped my program..' is, even it is true, in a sort of invalidating the gotten help, for the people who tried to help. Some of the help e.g. the hint for the unnecessary long names was very valueable even when this doesn't meet your main problem, but it will help you to get better coding when you follow the suggestions.
The sentece 'None of your replies helped my program..' is an absolutly unnecessary information. If you only state that your problem is still the same, we are informed that you still need help and thats enough to know and nobody will run into bad moods. In live we need a bit of diplomacy most times. As I know you are young I can tell you as earlier you learn it, the better you will go through the life. There is an easy rule you can use
a) Never do or say things to others you would yourself not like that others do or say them to you.
b) Learn to be able to expiere all, what is told or done to you.
(Without going in heavy emotions )
...HELLO! Now you're just lying. ...
Thats obviously an attack. Ok you felt attacked and so you shot back.
But doing that way you are going into a direction of a new firefight, as we had before in former post, remember.
If you read a post you should take a look to the reputation of the helper first, then you can decide what to do. People with high reputation are normally very helpful, so when they attack, there must a reason for it. Maybe the reason is only a misunderstood or misinterpreting of your post, maybe. But claimimg them a lier is like pouring oil into fire.
So never claim people to lie as ( see above points ) you yourself would not like someone tells about you. - Got it ?
..I DID tell you when it crashes. i told you that my program crashes when i click the calculate button without any input in the textboxes...
As much as I remember we have told you in older posts, that the error should be desribed with
a) The original line of code wher the crash occurs
b) If it happens at compilation the compiler error number and the message you get
c) if in runtime the name of the exception called with all detail information which you will see in the exception message.
This is what is expected as a correct information about a crash.
So in this case Mutant_Fruit was very right telling you, that you havn't told what the crash really is.
We dont have your code, so we need exact information. Very exact information, to give proper help.
So telling Mutant_Fruit a lier doesn't really help to calm his mood, isn't it. ?
Nobody can tell you if you should program or not. Sure. But thinking honestly about what I just have told you, do you wonder about ?
But I'm sure if you take back the 'lier' then he will also express that he's sorry about this statement. Understand - one word folows the other. Thats life :D
I for my sideI'm sure, if you take advantage of all we have tried to learn you in the last two month you will get a very good programmer one day. But itt needs a bit to jump over your own selfcreated borders.
# 16 Re: I cant stop this error XD
b) not unnecessary long
Sorry, sir ^^
I wasn't aware of that part... I tried to make them easy to understand, and i ditnt care about the lenght since Visual Studio writes them automaticly. All i had to write was "TextBox_" and then i guided after "1" or "2".
I'm honestly trying to improve all the time; hence defying my natural stubbornness :P
Cheers
dahwan at 2007-11-9 11:49:21 >

# 17 Re: I cant stop this error XD
b) not unnecessary long
Sorry, sir ^^I wasn't aware of that part... I tried to make them easy to understand, and i ditnt care about the lenght since Visual Studio writes them automaticly. All i had to write was "TextBox_" and then i guided after "1" or "2".
I'm honestly trying to improve all the time; hence defying my natural stubbornness :P
Cheers
And once again you prove that you do not read what is suggested...
(And BTW what means this signs ^^ in the end of the post ? I dont understand that ? Use the given smiles instead of strange signs. )
These are the things that cause people to get annoyed with you.
# 18 Re: I cant stop this error XD
Admin - Non English phrase removed. [/color]
Hi dahwan !
who is a bag of ( the word for excrements ) ?
# 19 Re: I cant stop this error XD
And once again you prove that you do not read what is suggested...
Sorry, what do you mean?
You're using an IDE. How could you not know...
Actually i was using Snippet Compiler at the moment ^^
Gives the cool colors and so forth, but it does not complete what i write :P
dahwan at 2007-11-9 11:52:22 >

# 20 Re: I cant stop this error XD
Hi dahwan !
who is a bag of ( the word for excrements ) ?
Thats deeply compressed into the norwegian language and was ment for laitinen only :D
dahwan at 2007-11-9 11:53:24 >

# 21 Re: I cant stop this error XD
Sorry, what do you mean?
Actually i was using Snippet Compiler at the moment ^^Gives the cool colors and so forth, but it does not complete what i write :P
What is so hard to understand. You keep putting ^^ symbols in your posts.
(And BTW what means this signs ^^ in the end of the post ? I dont understand that ? Use the given smiles instead of strange signs. )
# 22 Re: I cant stop this error XD
Thats deeply compressed into the norwegian language and was ment for laitinen only :DCome on ... a) If you want to be private use a private message.
b) If you use the forum dont and never use forbidden expressionss about others. As I told you in former times too.. I'm speaking german but I can understand norway as it is near to german better then you ever would like. So dont DONT DONT do that again.
# 23 Re: I cant stop this error XD
Okay, okay, calm down...
dahwan at 2007-11-9 11:56:30 >

# 24 Re: I cant stop this error XD
I wasn't aware of that part... I tried to make them easy to understand, and i ditnt care about the lenght since Visual Studio writes them automaticly.
Actually i was using Snippet Compiler at the moment ^^
Gives the cool colors and so forth, but it does not complete what i write :P
http://www.sliver.com/dotnet/SnippetCompiler/
Ye gods, this is the last time i answer one of your threads. The crap that you spout is hard to believe.
EDIT:
"Den derre muterte frukten er en ordentlig drittsekk "
Obviously i'd never think to use my advanced knowledge of germanic languages to try figure out what that means. I wouldn't even think of using google...
The mind, it really boggles.
# 25 Re: I cant stop this error XD
Obviously i'd never think to use my advanced knowledge of germanic languages to try figure out what that means. I wouldn't even think of using google...
.
Quote removed by Admin
The translation of that is approximatly something like ' the mothers of this guy(s) fruit is quite a great bag of excrements ' Dont telling whomabout he spokes and i'm not got enough to say if singular or plural is said.
So this brings bad opinion about this forum to just new other members.
# 26 Re: I cant stop this error XD
We ask that only English be used on the forum. This thread is closed due to some of the comments. If there are technical issues to still be addressed, then please start a new thread and focus on them.
Thanks,
Brad!