AHHHHH ok this is driving me nuts.
Why when does my decimal point in the wrong place e.g.
if i have the string 567 in the textbox and click the decimal button i would expect (or i want) the textbox to change to 567. but instead i get .567
It only goes into the correct place when i add another number e.g. if i had the number 4 then straight after doing the above I'd get 567.4
Edit:
Heres my whole 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;
using System.IO;
namespace Calculator
{
public partial class frmCurrencyCalc : Form
{
public frmCurrencyCalc()
{
InitializeComponent();
}
private void cmdZero_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "0";
}
else
{
txtScreen.AppendText("0");
}
}
private void cmd1_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "1";
}
else
{
txtScreen.AppendText("1");
}
}
private void cmdTwo_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "2";
}
else
{
txtScreen.AppendText("2");
}
}
private void cmdThree_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "3";
}
else
{
txtScreen.AppendText("3");
}
}
private void cmdFour_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "4";
}
else
{
txtScreen.AppendText("4");
}
}
private void cmdFive_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "5";
}
else
{
txtScreen.AppendText("5");
}
}
private void cmdSix_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "6";
}
else
{
txtScreen.AppendText("6");
}
}
private void cmdSeven_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "7";
}
else
{
txtScreen.AppendText("7");
}
}
private void cmdEight_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "8";
}
else
{
txtScreen.AppendText("8");
}
}
private void cmdNine_Click(object sender, EventArgs e)
{
if (txtScreen.Text == "0")
{
txtScreen.Text = "9";
}
else
{
txtScreen.AppendText("9");
}
}
private void cmdDecimal_Click(object sender, EventArgs e)
{
txtScreen.AppendText(".");
cmdDecimal.Enabled = false;
}
private void cmdCancel_Click(object sender, EventArgs e)
{
txtScreen.Text = "0";
cmdDecimal.Enabled = true;
}
}
}