C# 電卓処理作成中
やったこと。
テキストボックス内の文字列を判別。
↓
演算子の”+”を判別して
分岐を処理
・boolによるフラグ処理。
・文字列を 演算子の別で分ける。
例えば、
12 + 11
があったとして
12 =変数1
11 =変数2
+ 分岐処理
→変数1 + 変数2 で処理。
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
double stack = 0.0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
public void Cal()
{
if (textBox1.Text == "+")
{
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text += ((Button)sender).Text;
}
private void button4_Click(object sender, EventArgs e)
{
for (int i = 0; i < textBox1.Text.Length; ++i )
{
char Char_Temp = textBox1.Text[i];
if (Char_Temp == '+')
textBox2.Text = "+";
}
}
}
}