Parameter Passing with Arrays

The program you are about to see is known as a top down design this means that a problem is taken and broken down into smaller parts, worked out and executed.
You will see in this program that sub programs are used, these correspond to each level of the program this means that the program will run and only pick up on mistakes when it gets to that level. Also you could use breakpoints which will stop at the point you allocate the breakpoints too.
This type of program is known as a parameter this means that the pieces of information passes in and out of the program, to make the program work smoothly you must choose either byValue or byRefrence, by val means that the program does not change where as byref means the program will change.

Display the times table of the users choice
Option Explicit
Private sub CmdStart_Click()
‘Set up variables
Dim multiple As integer
‘Get Multiplier from user
Call GetValue(multiple)
‘Display table
Call DisplayTable(multiple)
End sub
Private sub GetValue(ByRef intvalue As Integer)
intvalue = InputBox(“Please enter the value”)
End sub
Private sub DisplayTable(ByVal multiple)
Dim Counter As Integer
Dim Answer As Integer

For counter = 1 to 12
Answer = multiple * counter
lstOutput.AddItem multiple & “X “ & Counter & “=” & Answer
Next
End Sub

Given you have typed in the correct coding the program should work however you need to look out for the byval and byref parts, in your second private sub because it is in the list box this will be what the answer is and multiple of your number, byVal is the correct one to use, however watch out if you put byRef in it’s place, this would keep the value as 0 and multiply by 0 and not the user’s input, this is because byVal stays the same meaning because the computers first number is 0 it will stay as 0, whereas byRef changes it and would therefore display the user’s input choice of multiple.