Simple Calculator

Topic Progress

Caclulator 1

You just need a Button

Double Click on the button and copy and paste the code below

Now your try!

1
2
3
4
5
6
7
        Dim num1 As Integer
        Dim num2 As Integer
        Dim answer As Integer
        num1 = 4
        num2 = 5
        answer = num1 + num2
        MsgBox(answer)

Challenge

  • change num1 to 7 and num2 to 12
  • change to make it take away
  • change to make it multiply. Use the star key *

Calculator 2

Add a label and 2 textboxes

Double click the button and replace the previous code with the code below

1
2
3
4
5
6
7
        Dim num1 As Integer
        Dim num2 As Integer

        num1 = TextBox1.Text
        num2 = TextBox2.Text

        Label1.Text = num1 + num2

Challenge

Add a button to take and button to multiply and change the first button to “Add”, copy and paste the code into the other buttons but it adds if you click on the add button and takes if you click on the take button…

Learn the code

num1 and num2 are variables because they can change. They are also integers because they are whole numbers E.g 12, 34

Look at the following code and answer the questions