Variable declaration is required with Option Explicit and a module level variable (answer) is declared.
Option Explicit
Dim answer As Integer
Sub Main()
Dim num1 As Integer
Dim num2 As Integer
num1 = Val(InputBox("Please enter the first addend", "First Addend"))
num2 = Val(InputBox("Please enter the second addend", "Second Addend"))
Call AddUserInput(num1, num2)
SendResult
End Sub
Private Sub AddUserInput(num1 As Integer, num2 As Integer)
answer = num1 + num2
End Sub
Private Sub SendResult()
MsgBox ("The answer is " & Str(answer))
End Sub
Related examples in the same category