<script
runat="server" language="c#">
private void Button1_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "1";
else
TextBox1.Text = "1";
}
private void Button2_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "2";
else
TextBox1.Text = "2";
}
private void Button3_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "3";
else
TextBox1.Text = "3";
}
private void Button4_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "4";
else
TextBox1.Text = "4";
}
private void Button5_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "5";
else
TextBox1.Text = "5";
}
private void Button6_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "6";
else
TextBox1.Text = "6";
}
private void Button7_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "7";
else
TextBox1.Text = "7";
}
private void Button8_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "8";
else
TextBox1.Text = "8";
}
private void Button9_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "9";
else
TextBox1.Text = "9";
}
private void Button10_Click(object sender, System.EventArgs e)
{
Label1.Text = TextBox1.Text;
Label2.Text = "+";
TextBox1.Text = "";
}
private void Button11_Click(object sender, System.EventArgs e)
{
Label1.Text = TextBox1.Text;
Label2.Text = "-";
TextBox1.Text = "";
}
private void Button12_Click(object sender, System.EventArgs e)
{
Label1.Text = TextBox1.Text;
Label2.Text = "*";
TextBox1.Text = "";
}
private void Button13_Click(object sender, System.EventArgs e)
{
Label1.Text = TextBox1.Text;
Label2.Text = "/";
TextBox1.Text = "";
}
private void Button14_Click(object sender, System.EventArgs e)
{
try
{
if (Label2.Text != "")
{
int n1 = Convert.ToInt32(Label1.Text);
int n2 = Convert.ToInt32(TextBox1.Text);
if (Label2.Text == "+")
{
TextBox1.Text = Convert.ToString(n1 + n2);
}
else if (Label2.Text == "-")
{
TextBox1.Text = Convert.ToString(n1 - n2);
}
else if (Label2.Text == "*")
{
TextBox1.Text = Convert.ToString(n1 * n2);
}
else if (Label2.Text == "+")
{
TextBox1.Text = Convert.ToString(n1 / n2);
}
}
Label2.Text = "=";
}
catch
{
Label2.Text = "에러입니다 제대로 입력해 주세요";
}
}
private void Button15_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "0";
Label1.Text = "";
Label2.Text = "";
}
private void Button16_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "0";
}
private void Button17_Click(object sender, System.EventArgs e)
{
try
{
TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length -
1);
}
catch
{
Label2.Text = "더이상 삭제할 숫자가 없습니다.";
}
}
private void Button18_Click(object sender, System.EventArgs e)
{
if (TextBox1.Text != "0")
TextBox1.Text += "00";
}
protected void Page_Load(object sender, EventArgs e)
{
}
</script>
<html>
<body>
<form id="form1" runat="server">
<table>
<asp:Label ID="Label1" runat="server" />
<asp:Label ID="Label2" runat="server" /><br/>
<asp:Label ID="TextBox1" runat="server" Font-Overline="False"
/><br/>
<tr>
<td><asp:button id="Button1" runat="server" text=" 1 "
onclick="Button1_Click" font-size="20" /></td>
<td><asp:button id="Button2" runat="server" text=" 2 "
onclick="Button2_Click" font-size="20"/></td>
<td><asp:button id="Button3" runat="server" text=" 3 "
onclick="Button3_Click" font-size="20"/></td>
<td><asp:button id="Button10" runat="server" text=" + "
onclick="Button10_Click" font-size="20"/></td>
</tr>
<tr>
<td><asp:button id="Button4" runat="server" text=" 4 "
onclick="Button4_Click" font-size="20"/></td>
<td><asp:button id="Button5" runat="server" text=" 5 "
onclick="Button5_Click" font-size="20"/></td>
<td><asp:button id="Button6" runat="server" text=" 6 "
onclick="Button6_Click" font-size="20"/></td>
<td><asp:button id="Button11" runat="server" text=" - "
onclick="Button11_Click" font-size="20"/></td>
</tr>
<tr>
<td><asp:button id="Button7" runat="server" text=" 7 "
onclick="Button7_Click" font-size="20"/></td>
<td><asp:button id="Button8" runat="server" text=" 8 "
onclick="Button8_Click" font-size="20"/></td>
<td><asp:button id="Button9" runat="server" text=" 9 "
onclick="Button9_Click" font-size="20"/></td>
<td><asp:button id="Button12" runat="server" text=" * "
onclick="Button12_Click"
font-size="20" Width="53px"/></td>
</tr>
<tr>
<td><asp:button id="Button15" runat="server" text=" C "
onclick="Button15_Click"
font-size="20" Width="52px"/></td>
<td><asp:button id="Button16" runat="server" text=" 0 "
onclick="Button16_Click" font-size="20"/></td>
<td><asp:button id="Button18" runat="server" text=" 00 "
onclick="Button18_Click"
font-size="20" Width="48px"/></td>
<td><asp:button id="Button13" runat="server" text=" / "
onclick="Button13_Click"
font-size="20" Width="53px"/></td>
<tr>
<td><asp:button id="Button17" runat="server" text=" ← "
onclick="Button17_Click"
font-size="20" Width="53px"/></td>
<td><asp:button id="Button14" runat="server" text=" = "
onclick="Button14_Click"
font-size="20" Width="51px"/></td>
</tr>
</table>
</form>
</body>
</html>
댓글 없음:
댓글 쓰기