In this post we will try to learn simple calculator using vb.net. Through VB.NET we can develop many simple and advanced software. We are making this calculator for teaching purpose only. Because calculator has made our life very easy. That is, we can calculate crores and lakhs within seconds. For this we have to create three tax boxes. In one we will enter the first number. In the second we will enter the second number. And our answer will be known in the third box. At the same time we have to put four buttons. The complete coding of which is given below.

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text) TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text) TextBox4.Text = TextBox1.Text & " + " & TextBox2.Text & " = " & TextBox3.Text End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text) TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text) TextBox4.Text = TextBox1.Text & " - " & TextBox2.Text & " = " & TextBox3.Text End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text) TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text) TextBox4.Text = TextBox1.Text & " x " & TextBox2.Text & " = " & TextBox3.Text End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox4.Text = Val(TextBox1.Text) / Val(TextBox2.Text) TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text) TextBox4.Text = TextBox1.Text & " / " & TextBox2.Text & " = " & TextBox3.Text End Sub End Class
 
Top