Click here to Skip to main content
15,907,396 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Which is the best way to set default value for properties Pin
DaveAuld28-Apr-10 3:24
professionalDaveAuld28-Apr-10 3:24 
QuestionMultithread Error (Input string was not in the correct format)? [modified] Pin
Dominick Marciano27-Apr-10 13:49
professionalDominick Marciano27-Apr-10 13:49 
AnswerRe: Multithread Error (Input string was not in the correct format)? Pin
Luc Pattyn27-Apr-10 14:18
sitebuilderLuc Pattyn27-Apr-10 14:18 
QuestionHow to display access records in Visual Basic 2008 form? Pin
Razanust27-Apr-10 2:27
Razanust27-Apr-10 2:27 
AnswerRe: How to display access records in Visual Basic 2008 form? Pin
Dave Kreskowiak27-Apr-10 2:39
mveDave Kreskowiak27-Apr-10 2:39 
QuestionHow to avoid a group box using mixed with other group boxes while overlapping in VB 6 Pin
Razanust26-Apr-10 15:27
Razanust26-Apr-10 15:27 
AnswerRe: How to avoid a group box using mixed with other group boxes while overlapping in VB 6 Pin
DaveAuld26-Apr-10 23:21
professionalDaveAuld26-Apr-10 23:21 
Questionvisual basic simple calculator Pin
terrable26-Apr-10 11:17
terrable26-Apr-10 11:17 
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(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button8.Text = button8.Text + "8";
}

private void button9_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button9.Text = button9.Text + "9";
}
//dont want more than one decimal on the screen
private void buttonDecimal_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text = "";
equals = false;
}
if (buttonDecimal.Text.contains("."))
{
return;
}
else
{
buttonDecimal.Text.contains + ".";

}
}






//if already neg it will become pos
private void buttonNeg_Click(object sender, EventArgs e)
{
if (buttonNeg.Text.contain("-"))
{
textBox1.Text = textBox1.Text.Remove(0,1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}

private void buttonPlus_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Plus = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}

}

private void buttonEquals_Click(object sender, EventArgs e)
{
equals = true;
if(Plus)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
if (Multiply)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();

}
if (Sub)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
if (Divide)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
}

private void buttonSub_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Sub = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}

private void buttonDivide_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Divide = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}

private void buttonMultiply_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Multiply = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}
private void buttonclear_Click(object sender, EventArgs e)
{
Plus= Sub = Multiply = Divide = false;
textBox1.Text = "";
textBox1.Tag ="";//clear stores number
}



}
}
AnswerRe: visual basic simple calculator Pin
Richard MacCutchan26-Apr-10 11:42
mveRichard MacCutchan26-Apr-10 11:42 
AnswerRe: visual basic simple calculator Pin
Luc Pattyn26-Apr-10 11:57
sitebuilderLuc Pattyn26-Apr-10 11:57 
AnswerRe: visual basic simple calculator Pin
Steven J Jowett26-Apr-10 21:38
Steven J Jowett26-Apr-10 21:38 
JokeRe: visual basic simple calculator Pin
Michel Godfroid27-Apr-10 1:21
Michel Godfroid27-Apr-10 1:21 
Questionmeaning of code Pin
skskhoukhita201026-Apr-10 5:25
skskhoukhita201026-Apr-10 5:25 
AnswerRe: meaning of code Pin
Michel Godfroid26-Apr-10 5:40
Michel Godfroid26-Apr-10 5:40 
GeneralRe: meaning of code Pin
Eddy Vluggen26-Apr-10 5:54
professionalEddy Vluggen26-Apr-10 5:54 
AnswerRe: meaning of code Pin
Eddy Vluggen26-Apr-10 5:50
professionalEddy Vluggen26-Apr-10 5:50 
GeneralRe: meaning of code Pin
skskhoukhita201026-Apr-10 6:04
skskhoukhita201026-Apr-10 6:04 
QuestionHow to sent Mail in VB6.0 Pin
JC.KaNNaN25-Apr-10 21:04
JC.KaNNaN25-Apr-10 21:04 
AnswerRe: How to sent Mail in VB6.0 Pin
Dalek Dave25-Apr-10 22:14
professionalDalek Dave25-Apr-10 22:14 
GeneralRe: How to sent Mail in VB6.0 Pin
Wayne Gaylard25-Apr-10 22:39
professionalWayne Gaylard25-Apr-10 22:39 
GeneralRe: How to sent Mail in VB6.0 Pin
Tom Deketelaere25-Apr-10 23:52
professionalTom Deketelaere25-Apr-10 23:52 
GeneralRe: How to sent Mail in VB6.0 Pin
Eddy Vluggen26-Apr-10 0:20
professionalEddy Vluggen26-Apr-10 0:20 
GeneralRe: How to sent Mail in VB6.0 Pin
Tom Deketelaere26-Apr-10 0:32
professionalTom Deketelaere26-Apr-10 0:32 
GeneralRe: How to sent Mail in VB6.0 Pin
Eddy Vluggen26-Apr-10 0:58
professionalEddy Vluggen26-Apr-10 0:58 
GeneralRe: How to sent Mail in VB6.0 Pin
Steven J Jowett25-Apr-10 23:56
Steven J Jowett25-Apr-10 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.