Simple Caculator

This is a very simple calculator that allows you to calculate addition, subtraction, multiplication, and division.
  1. Public Class Form1
  2.  
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.  
  5. If (TextBox1.Text = " ") Then
  6. MessageBox.Show("enter value in num1")
  7. End If
  8. If (TextBox2.Text = " ") Then
  9. MessageBox.Show("enter value in num2")
  10. Else
  11. TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
  12. End If
  13.  
  14. End Sub
  15.  
  16. Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
  17.  
  18. End Sub
  19.  
  20. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  21.  
  22. If (TextBox1.Text = " ") Then
  23. MessageBox.Show("enter value in num1")
  24. End If
  25. If (TextBox2.Text = " ") Then
  26. MessageBox.Show("enter value in num2")
  27. Else
  28. TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
  29. End If
  30. End Sub
  31.  
  32. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  33. TextBox1.Text = " "
  34. TextBox2.Text = " " 'clear button to clear all numbers.
  35. TextBox3.Text = " "
  36.  
  37.  
  38.  
  39. End Sub
  40.  
  41. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  42. Form2.Show() 'show exit form.
  43. End Sub
  44.  
  45.  
  46. Private Sub abstract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles abstract.Click
  47. If (TextBox1.Text = " ") Then
  48. MessageBox.Show("enter value in num1")
  49. End If
  50. If (TextBox2.Text = " ") Then
  51. MessageBox.Show("enter value in num2")
  52. Else
  53. TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
  54. End If
  55.  
  56. End Sub
  57.  
  58. Private Sub division_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles division.Click
  59. If (TextBox1.Text = " ") Then
  60. MessageBox.Show("enter value in num1")
  61. End If
  62. If (TextBox2.Text = " ") Then
  63. MessageBox.Show("enter value in num2")
  64. Else
  65. TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
  66. End If
  67. End Sub
  68.  
  69. Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  70.  
  71. End Sub
  72. End Class
  73.  
  74. Public Class Form2
  75.  
  76. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  77. Me.Close() ' if no button close form2 &keep app on.
  78.  
  79.  
  80.  
  81. End Sub
  82.  
  83. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  84.  
  85. Form1.Close() 'close form1.
  86.  
  87. Me.Close() 'close form2 .
  88.  
  89.  
  90.  
  91. End Sub
  92.  
  93. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  94.  
  95. End Sub
  96. End Class

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment