Calculator code

933 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
933
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Calculator code

  1. 1. Public Class Form1Dim total As DoubleDim total1 As DoubleDim operation As StringPrivate Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handleszero.ClickTextBox1.Text = TextBox1.Text & zero.TextEnd SubPrivate Sub one_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesone.ClickTextBox1.Text = TextBox1.Text & one.TextEnd SubPrivate Sub two_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlestwo.ClickTextBox1.Text = TextBox1.Text & two.TextEnd SubPrivate Sub three_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesthree.ClickTextBox1.Text = TextBox1.Text & three.TextEnd SubPrivate Sub four_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesfour.ClickTextBox1.Text = TextBox1.Text & four.TextEnd SubPrivate Sub five_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesfive.ClickTextBox1.Text = TextBox1.Text & five.TextEnd SubPrivate Sub six_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlessix.ClickTextBox1.Text = TextBox1.Text & six.TextEnd SubPrivate Sub seven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesseven.ClickTextBox1.Text = TextBox1.Text & seven.TextEnd SubPrivate Sub eight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handleseight.ClickTextBox1.Text = TextBox1.Text & eight.TextEnd SubPrivate Sub nine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesnine.ClickTextBox1.Text = TextBox1.Text & nine.TextEnd SubPrivate Sub plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesplus.Clickoperation = "+"
  2. 2. total = total + Val(TextBox1.Text)TextBox1.Text = " "End SubPrivate Sub Mul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMul.Clickoperation = "*"total = total + Val(TextBox1.Text)TextBox1.Text = " "End SubPrivate Sub equal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesequal.ClickIf operation = "+" Thentotal1 = total + Val(TextBox1.Text)total = 0ElseIf operation = "*" Thentotal1 = total * Val(TextBox1.Text)total = 0ElseIf operation = "-" Thentotal1 = total - Val(TextBox1.Text)total = 0ElseIf operation = "" Thentotal1 = total Val(TextBox1.Text)total = 0End IfTextBox1.Text = total1.ToString()End SubPrivate Sub minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesminus.Clickoperation = "-"total = total + Val(TextBox1.Text)TextBox1.Text = " "End SubPrivate Sub div_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesdiv.Clickoperation = ""total = total + Val(TextBox1.Text)TextBox1.Text = " "End SubPrivate Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesCancel.ClickTextBox1.Text = " "End SubPrivate Sub CE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesCE.ClickTextBox1.Text = ""total1 = 0End SubPrivate Sub dot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handlesdot.Click
  3. 3. TextBox1.Text = TextBox1.Text & "."End SubEnd Class

×