Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  3.  
  4.     End Sub
  5.  
  6.     Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click
  7.         If Button22.Text = 1 Then
  8.             Button22.Text = 2
  9.         ElseIf Button22.Text = 2 Then
  10.             Button22.Text = 1
  11.         End If
  12.     End Sub
  13.  
  14.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  15.         If Button22.Text = 1 Then
  16.             TextBox1.Text = TextBox1.Text & "1"
  17.         ElseIf Button22.Text = 2 Then
  18.             TextBox2.Text = TextBox2.Text & "1"
  19.         End If
  20.     End Sub
  21.  
  22.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  23.         If Button22.Text = 1 Then
  24.             TextBox1.Text = TextBox1.Text & "2"
  25.         ElseIf Button22.Text = 2 Then
  26.             TextBox2.Text = TextBox2.Text & "2"
  27.         End If
  28.     End Sub
  29.  
  30.     Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  31.         If Button22.Text = 1 Then
  32.             TextBox1.Text = TextBox1.Text & "3"
  33.         ElseIf Button22.Text = 2 Then
  34.             TextBox2.Text = TextBox2.Text & "3"
  35.         End If
  36.     End Sub
  37.  
  38.     Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  39.         If Button22.Text = 1 Then
  40.             TextBox1.Text = TextBox1.Text & "4"
  41.         ElseIf Button22.Text = 2 Then
  42.             TextBox2.Text = TextBox2.Text & "4"
  43.         End If
  44.     End Sub
  45.  
  46.     Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  47.         If Button22.Text = 1 Then
  48.             TextBox1.Text = TextBox1.Text & "5"
  49.         ElseIf Button22.Text = 2 Then
  50.             TextBox2.Text = TextBox2.Text & "5"
  51.         End If
  52.     End Sub
  53.  
  54.     Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  55.         If Button22.Text = 1 Then
  56.             TextBox1.Text = TextBox1.Text & "6"
  57.         ElseIf Button22.Text = 2 Then
  58.             TextBox2.Text = TextBox2.Text & "6"
  59.         End If
  60.     End Sub
  61.  
  62.     Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  63.         If Button22.Text = 1 Then
  64.             TextBox1.Text = TextBox1.Text & "7"
  65.         ElseIf Button22.Text = 2 Then
  66.             TextBox2.Text = TextBox2.Text & "7"
  67.         End If
  68.     End Sub
  69.  
  70.     Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  71.         If Button22.Text = 1 Then
  72.             TextBox1.Text = TextBox1.Text & "8"
  73.         ElseIf Button22.Text = 2 Then
  74.             TextBox2.Text = TextBox2.Text & "8"
  75.         End If
  76.     End Sub
  77.  
  78.     Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  79.         If Button22.Text = 1 Then
  80.             TextBox1.Text = TextBox1.Text & "9"
  81.         ElseIf Button22.Text = 2 Then
  82.             TextBox2.Text = TextBox2.Text & "9"
  83.         End If
  84.     End Sub
  85.  
  86.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  87.         If Button22.Text = 1 Then
  88.             If TextBox1.Text <> "" Then
  89.                 TextBox1.Text = TextBox1.Text & "0"
  90.             End If
  91.         ElseIf Button22.Text = 2 Then
  92.             If TextBox2.Text <> "" Then
  93.                 TextBox2.Text = TextBox2.Text & "0"
  94.             End If
  95.         End If
  96.     End Sub
  97.  
  98.     Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  99.         If Button22.Text = 1 Then
  100.             If TextBox1.Text = "" Then
  101.                 TextBox1.Text = TextBox1.Text & "0."
  102.             Else
  103.                 TextBox1.Text = TextBox1.Text & "."
  104.             End If
  105.         ElseIf Button22.Text = 2 Then
  106.             If TextBox2.Text = "" Then
  107.                 TextBox2.Text = TextBox2.Text & "0."
  108.             Else
  109.                 TextBox1.Text = TextBox1.Text & "."
  110.             End If
  111.         End If
  112.     End Sub
  113.  
  114.     Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  115.         Label1.Text = "+"
  116.     End Sub
  117.  
  118.     Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
  119.         Label1.Text = "*"
  120.     End Sub
  121.  
  122.     Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
  123.         Label1.Text = "-"
  124.     End Sub
  125.  
  126.     Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  127.         Label1.Text = "/"
  128.     End Sub
  129.  
  130.     Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click
  131.         Label1.Text = "O"
  132.         TextBox1.Text = ""
  133.         TextBox2.Text = ""
  134.         TextBox3.Text = ""
  135.     End Sub
  136.  
  137.     Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  138.         If Button22.Text = 1 And TextBox1.Text <> "" Then
  139.             If TextBox1.Text.Substring(0, 1) = "-" Then
  140.                 TextBox1.Text.Remove(0, 1)
  141.             Else
  142.                 TextBox1.Text = "-" & TextBox1.Text
  143.             End If
  144.         ElseIf Button22.Text = 2 And TextBox2.Text <> "" Then
  145.             If TextBox2.Text.Substring(0, 1) = "-" Then
  146.                 TextBox2.Text.Remove(0, 1)
  147.             Else
  148.                 TextBox2.Text = "-" & TextBox2.Text
  149.             End If
  150.         End If
  151.     End Sub
  152.  
  153.     Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
  154.         If Button22.Text = 1 And TextBox1.Text <> "" Then
  155.             Try
  156.                 Dim hasil As Double = CDbl(TextBox1.Text)
  157.                 hasil = Math.Sqrt(hasil)
  158.                 TextBox1.Text = hasil
  159.             Catch ex As Exception
  160.                 MsgBox("Operation Failed")
  161.             End Try
  162.         ElseIf Button22.Text = 2 And TextBox2.Text <> "" Then
  163.             Try
  164.                 Dim hasil As Double = CDbl(TextBox2.Text)
  165.                 hasil = Math.Sqrt(hasil)
  166.                 TextBox2.Text = hasil
  167.             Catch ex As Exception
  168.                 MsgBox("Operation Failed")
  169.             End Try
  170.         End If
  171.     End Sub
  172.  
  173.     Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
  174.         If Button22.Text = 1 And TextBox1.Text <> "" Then
  175.             Try
  176.                 Dim hasil As Double = CDbl(TextBox1.Text)
  177.                 hasil = hasil / 100
  178.                 TextBox1.Text = hasil
  179.             Catch ex As Exception
  180.                 MsgBox("Operation Failed")
  181.             End Try
  182.         ElseIf Button22.Text = 2 And TextBox2.Text <> "" Then
  183.             Try
  184.                 Dim hasil As Double = CDbl(TextBox2.Text)
  185.                 hasil = hasil / 100
  186.                 TextBox2.Text = hasil
  187.             Catch ex As Exception
  188.                 MsgBox("Operation Failed")
  189.             End Try
  190.         End If
  191.     End Sub
  192.  
  193.     Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
  194.         If Button22.Text = 1 And TextBox1.Text <> "" Then
  195.             Try
  196.                 Dim hasil As Double = CDbl(TextBox1.Text)
  197.                 hasil = 1 / hasil
  198.                 TextBox1.Text = hasil
  199.             Catch ex As Exception
  200.                 MsgBox("Operation Failed")
  201.             End Try
  202.         ElseIf Button22.Text = 2 And TextBox2.Text <> "" Then
  203.             Try
  204.                 Dim hasil As Double = CDbl(TextBox2.Text)
  205.                 hasil = 1 / hasil
  206.                 TextBox2.Text = hasil
  207.             Catch ex As Exception
  208.                 MsgBox("Operation Failed")
  209.             End Try
  210.         End If
  211.     End Sub
  212.  
  213.     Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
  214.         Try
  215.             Dim num1 As Double = CDbl(TextBox1.Text)
  216.             Dim num2 As Double = CDbl(TextBox2.Text)
  217.  
  218.             If Label1.Text = "+" Then
  219.                 Dim hasil As Double = num1 + num2
  220.                 TextBox3.Text = hasil
  221.             ElseIf Label1.Text = "*" Then
  222.                 Dim hasil As Double = num1 * num2
  223.                 TextBox3.Text = hasil
  224.             ElseIf Label1.Text = "/" Then
  225.                 Dim hasil As Double = num1 / num2
  226.                 TextBox3.Text = hasil
  227.             ElseIf Label1.Text = "-" Then
  228.                 Dim hasil As Double = num1 - num2
  229.                 TextBox3.Text = hasil
  230.             Else
  231.                 MsgBox("Operator belum dipilih")
  232.             End If
  233.         Catch ex As Exception
  234.             MsgBox("Operation Failed")
  235.         End Try
  236.     End Sub
  237. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement