Guest User

Simple calculator , easy to understand

a guest
Jun 18th, 2015
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.72 KB | None | 0 0
  1. 'By HugoTheBaws @ nulled.io
  2.  
  3.         Try ' a try statement will try to do what's below
  4.             Dim num01 As Double ' we dimension num01 as a double, double is a number that contains decimals (ex : 9,32718), while an Integer is a number that does not contain decimals (ex: 10)
  5.             Dim num02 As Double ' same thing we did for num01, but this time using num02
  6.  
  7.             Dim ans As Double ' ans is going to be our answer, we will need to dimension as double and not as integer for very accurate results
  8.  
  9.             num01 = num1TXT.Text ' tells num01 that its value is what is written in the 1st textbox
  10.             num02 = num2TXT.Text ' tells num02 that its value is what is written in the 2nd textbox
  11.  
  12.  
  13.             If plus.Checked = True Then ' if statement, if the radiobutton "plus" ( + ) is checked, the ans will be num01 + num02
  14.                 ans = num01 + num02
  15.             ElseIf minus.Checked = True Then ' if its not that, it will jump into this statement which will do num01 - num02
  16.                 ans = num01 - num02
  17.             ElseIf multiply.Checked = True Then ' this time ans = num01 x num02
  18.                 ans = num01 * num02
  19.             ElseIf divide.Checked = True Then ' and finally this will make ans be num01 divided by num02
  20.                 ans = num01 / num02
  21.             End If
  22.  
  23.             'if statment ended right here
  24.  
  25.             ansTXT.Text = ans ' basically tells the 3rd textbox that its value is ans
  26.  
  27.         Catch ex As Exception 'if try statment catches ex as an exception (ex can be replaced by other name, this is the default one)
  28.             MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Unhandled exception!") ' pops up a messagebox saying what exception has ocurred
  29.         End Try
Advertisement
Add Comment
Please, Sign In to add comment