계산기 만들기.

네크 2014.02.23 22:29:45 *: Public Class Form1

Private Sub txtagent(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox3.KeyPress, TextBox2.KeyPress
If Not (Char.IsDigit(e.KeyChar) OrElse e.KeyChar = Convert.ToChar(Keys.Back)) Then
e.Handled = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
Label2.Text = "+"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
Label2.Text = "-"
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
Label2.Text = "*"
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
Label2.Text = "/"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
Label2.Text = ""
End Sub
End Class

간단한 계산기 만들기 입니다.

숫자만 인식하게하였고 오류메세지를 뜨게 만들어 보세여.

 

조금더 복잡한 계산기를 만들어 보세여.