Advertisement
TechOPGOHIL

Untitled

Dec 30th, 2023
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.81 KB | None | 0 0
  1. Public Class Calculater
  2.     Dim a, b, c As Integer
  3.     Dim sign As String
  4.  
  5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6.         Textbox1.Text = 1 & Textbox1.Text
  7.     End Sub
  8.  
  9.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  10.         Textbox1.Text = Textbox1.Text & 2
  11.     End Sub
  12.  
  13.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  14.         Textbox1.Text = Textbox1.Text & 3
  15.     End Sub
  16.  
  17.     Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  18.         Textbox1.Text = Textbox1.Text & 4
  19.     End Sub
  20.  
  21.     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  22.         Textbox1.Text = Textbox1.Text & 5
  23.     End Sub
  24.  
  25.     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  26.         Textbox1.Text = Textbox1.Text & 6
  27.     End Sub
  28.  
  29.     Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
  30.         Textbox1.Text = Textbox1.Text & 7
  31.     End Sub
  32.  
  33.     Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
  34.         Textbox1.Text = Textbox1.Text & 8
  35.     End Sub
  36.  
  37.     Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
  38.         Textbox1.Text = Textbox1.Text & 9
  39.     End Sub
  40.  
  41.     Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
  42.         Textbox1.Text = Textbox1.Text & 0
  43.     End Sub
  44.  
  45.     Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
  46.         Textbox1.Clear()
  47.         TextBox2.Clear()
  48.         Textbox1.Focus()
  49.     End Sub
  50.  
  51.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  52.         TextBox2.Text = Textbox1.Text + "+"
  53.         a = Textbox1.Text
  54.         Textbox1.Clear()
  55.         Textbox1.Focus()
  56.         sign = "+"
  57.     End Sub
  58.  
  59.     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  60.         TextBox2.Text = Textbox1.Text + "-"
  61.         a = Textbox1.Text
  62.         Textbox1.Clear()
  63.         Textbox1.Focus()
  64.         sign = "-"
  65.     End Sub
  66.  
  67.     Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
  68.         TextBox2.Text = Textbox1.Text + "*"
  69.         a = Textbox1.Text
  70.         Textbox1.Clear()
  71.         Textbox1.Focus()
  72.         sign = "*"
  73.     End Sub
  74.  
  75.     Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
  76.         TextBox2.Text = Textbox1.Text + "/"
  77.         a = Textbox1.Text
  78.         Textbox1.Clear()
  79.         Textbox1.Focus()
  80.         sign = "/"
  81.     End Sub
  82.  
  83.     Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
  84.         b = Textbox1.Text
  85.  
  86.         If sign = "+" Then
  87.             Textbox1.Text = a + b
  88.             TextBox2.Clear()
  89.             TextBox2.Text = a.ToString + "+" + b.ToString
  90.         ElseIf sign = "-" Then
  91.             Textbox1.Text = a - b
  92.             TextBox2.Clear()
  93.             TextBox2.Text = a.ToString + "-" + b.ToString
  94.         ElseIf sign = "*" Then
  95.             Textbox1.Text = a * b
  96.             TextBox2.Clear()
  97.             TextBox2.Text = a.ToString + "*" + b.ToString
  98.         ElseIf sign = "/" Then
  99.             Textbox1.Text = a / b
  100.             TextBox2.Clear()
  101.             TextBox2.Text = a.ToString + "/" + b.ToString
  102.  
  103.         End If
  104.     End Sub
  105. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement