Vb.Net Calculator Ver. 1.0

Hello, this source code demonstrates how to create a basic calculator using Visual Basic.Net This Calculator application can perform two tasks i.e Addition and Subtraction of whole numbers. Global Variables
  1. Dim operater_on As Boolean = False
  2. Dim operater As String = ""
  3. Dim val1, val2 As Double
Form Load Event
  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2. AddHandler btn0.Click, AddressOf buttonClick
  3. AddHandler btn1.Click, AddressOf buttonClick
  4. AddHandler btn2.Click, AddressOf buttonClick
  5. AddHandler btn3.Click, AddressOf buttonClick
  6. AddHandler btn4.Click, AddressOf buttonClick
  7. AddHandler btn5.Click, AddressOf buttonClick
  8. AddHandler btn6.Click, AddressOf buttonClick
  9. AddHandler btn7.Click, AddressOf buttonClick
  10. AddHandler btn8.Click, AddressOf buttonClick
  11. AddHandler btn9.Click, AddressOf buttonClick
  12. End Sub
Number buttons click handler
  1. Private Sub buttonClick(sender As Object, e As EventArgs)
  2.  
  3. Dim btn As Button = DirectCast(sender, System.Windows.Forms.Button)
  4. If lblDisplay.Text = "0" Or operater_on = True Then
  5. lblDisplay.Text = btn.Text
  6. operater_on = False
  7. Else
  8. lblDisplay.Text = lblDisplay.Text & btn.Text
  9. End If
  10. End Sub
I also welcome other developers to submit their codes such that we build a good network of learning for free.

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