Code for making a Calculater in VB.NET


This is program code for making a calculator in VB.NET.

PROGRAM CODE FOR HOW TO MAKE A CALCULATER IN VB.NET



Public Class Form1
Dim a As Double
Dim c As Double
Dim b As Char



Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TextBox1.Text += "7"


End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TextBox1.Text += "8"

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
TextBox1.Text += "9"

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox1.Text += "4"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text += "1"

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text += "2"
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text += "3"
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox1.Text += "5"
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox1.Text += "6"
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
TextBox1.Text += "0"
End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
TextBox1.Text += "."
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "+"
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If b = "+" Then
TextBox1.Text = a + TextBox1.Text
ElseIf b = "-" Then
TextBox1.Text = a - TextBox1.Text
ElseIf b = "*" Then
TextBox1.Text = a * TextBox1.Text
ElseIf b = "/" Then
TextBox1.Text = a / TextBox1.Text
ElseIf b = "%" Then
TextBox1.Text = a \ TextBox1.Text
ElseIf b = "p" Then
c = TextBox1.Text
TextBox1.Text = Math.Pow(a, c)
End If

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "-"
End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "*"
End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "/"
End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "%"
End Sub

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
a = TextBox1.Text
TextBox1.Text = ""
b = "p"
End Sub

Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
TextBox1.Text = Math.Sqrt(TextBox1.Text)
End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
a = 0
c = 0
b = ""
TextBox1.Text = ""
End Sub

Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
If TextBox1.Text = "" Then
Return
End If
Dim l As Integer
l = TextBox1.Text.Length
TextBox1.Text = TextBox1.Text.Remove(l - 1, 1)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: