visual basic simple calculator
-
i am trying to make a working simple calculator in VB. i have 4 errors that i just can not figure out to save my life. can anyone help 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 projectfinal { public partial class Calculator : Form { bool Plus = false; bool Sub = false; bool Multiply = false; bool Divide = false; bool equals = false; public Calculator() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //clears textbox and starts new problem if (equals) { textBox1.Text =""; equals = false; } textBox1.Text = textBox1.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button2.Text = button2.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button3.Text = button3.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (equals) { textBox1.Text = ""; equals = false; button4.Text = button4.Text + "4"; } } private void button5_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button5.Text = button5.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button6.Text = button6.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button7.Text = button7.Text + "7"; } private void button8_Click
-
i am trying to make a working simple calculator in VB. i have 4 errors that i just can not figure out to save my life. can anyone help 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 projectfinal { public partial class Calculator : Form { bool Plus = false; bool Sub = false; bool Multiply = false; bool Divide = false; bool equals = false; public Calculator() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //clears textbox and starts new problem if (equals) { textBox1.Text =""; equals = false; } textBox1.Text = textBox1.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button2.Text = button2.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button3.Text = button3.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (equals) { textBox1.Text = ""; equals = false; button4.Text = button4.Text + "4"; } } private void button5_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button5.Text = button5.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button6.Text = button6.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button7.Text = button7.Text + "7"; } private void button8_Click
Some suggestions: 1. Put your code between <pre></pre> tags for readability; use the "code block" button in this editor. 2. Tell us what the errors are, we cannot see the output of your compilation from here, nor can we guess what might be going wrong.
It's time for a new signature.
-
i am trying to make a working simple calculator in VB. i have 4 errors that i just can not figure out to save my life. can anyone help 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 projectfinal { public partial class Calculator : Form { bool Plus = false; bool Sub = false; bool Multiply = false; bool Divide = false; bool equals = false; public Calculator() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //clears textbox and starts new problem if (equals) { textBox1.Text =""; equals = false; } textBox1.Text = textBox1.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button2.Text = button2.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button3.Text = button3.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (equals) { textBox1.Text = ""; equals = false; button4.Text = button4.Text + "4"; } } private void button5_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button5.Text = button5.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button6.Text = button6.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button7.Text = button7.Text + "7"; } private void button8_Click
on top of what Richard said, don't enter that amount of code all at once; start with a subset and get that working; working more incrementally will save you lots of time, so you can learn while doing, and not repeat earlier mistakes. I compile and run every two minutes, and I don't add code when what I have isn't working already to some extent. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
modified on Monday, April 26, 2010 7:07 PM
-
i am trying to make a working simple calculator in VB. i have 4 errors that i just can not figure out to save my life. can anyone help 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 projectfinal { public partial class Calculator : Form { bool Plus = false; bool Sub = false; bool Multiply = false; bool Divide = false; bool equals = false; public Calculator() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //clears textbox and starts new problem if (equals) { textBox1.Text =""; equals = false; } textBox1.Text = textBox1.Text + "1"; } private void button2_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button2.Text = button2.Text + "2"; } private void button3_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button3.Text = button3.Text + "3"; } private void button4_Click(object sender, EventArgs e) { if (equals) { textBox1.Text = ""; equals = false; button4.Text = button4.Text + "4"; } } private void button5_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button5.Text = button5.Text + "5"; } private void button6_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button6.Text = button6.Text + "6"; } private void button7_Click(object sender, EventArgs e) { if (equals) { textBox1.Text =""; equals = false; } button7.Text = button7.Text + "7"; } private void button8_Click
terrable wrote:
i am trying to make a working simple calculator in VB
I think you're biggest problem is that the code you provided is actually C# and not VB
Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.
-
terrable wrote:
i am trying to make a working simple calculator in VB
I think you're biggest problem is that the code you provided is actually C# and not VB
Steve Jowett ------------------------- Real programmers don't comment their code. If it was hard to write, it should be hard to read.
Steven J Jowett wrote:
I think you're biggest problem is that the code you provided is actually C# and not VB
We have a winner! :laugh: