Hi Guys,
Yeh Basic Calculator main ne practice ke liye
banaya tha, lekin main ne socha ke aap ke
saath share karon.
Image:
Yeh Source code hai:
Code:Public Class frmPlus Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click 'Declared two Decimal Variables Dim num1 As Decimal Dim num2 As Decimal Dim answer As Decimal ' Converted Text box and applyed their values to integers/ stored in variable num1 = Decimal.Parse(txtfirstnum.Text) num2 = Decimal.Parse(txtsecondnum.Text) ' Applied Value's stored in variables to answer label If lblsign.Text = "+" Then answer = num1 + num2 ElseIf lblsign.Text = "-" Then answer = num1 - num2 ElseIf lblsign.Text = "*" Then answer = num1 * num2 Else answer = num1 / num2 End If lblAnswer.Text = answer End Sub Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblheading.Click End Sub Private Sub cmdplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplus.Click lblsign.Text = "+" End Sub Private Sub cmdminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdminus.Click lblsign.Text = "-" End Sub Private Sub cmdmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdmultiply.Click lblsign.Text = "*" End Sub Private Sub cmddivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddivide.Click lblsign.Text = "/" End Sub Private Sub cmdac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdac.Click txtfirstnum.Clear() txtsecondnum.Clear() lblAnswer.Text = "Answer" End Sub Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click Me.Close() End Sub End Class
Project Source and Excutable file link --> VB Calculator + Source!
I hope you guys like it,
Thnx
Bookmarks