Functions

Topic Progress

A simple program that uses a function to add 3 and take 3 rom a total. It also has a reset button

You will need

  • 3 buttons
  • 1 label

click on the form and past the code to make the function
GCSE Computer Science

1
2
3
4
5
6
Dim total As Integer
 Function findTotal(ByVal num1 As Integer)
        total = total + num1
        Label1.Text = total
        Return total
    End Function

click on the Add 3 button and paste the following code

1
findTotal(3)

click on the take 3 button and paste the following code

1
findTotal(-3)

run your program and test
click on the reset button and paste the following code

1
2
total = 0
Label1.Text = total

See all code below

Coding Challenge

Add more buttons such as add 5 add 7 and test