You wanted the best? You got the best. Ladies and gentlemen, the lesson from 11th of November

In computing today we started off with Local and Global variables. Local Variables exist only within a single subroutine, and  cannot be accessed from elsewhere in the code.

Global Variables are created in the main part of the program that can be seen from any part of the program.

We then moved on to Arrays where we learned that ARRAYS ARE ALWAYS PASSED BY REFERENCE!!!!!!!!!!

Which means that data is passed in to a subroutine where it can be changed and then passed back out to other parts of the program.

We then had to code up a program that took and input from the user and passed that value by reference to other subroutines.

Here is the code for that program

Option Explicit
Private Sub CmdStart_Click()
'Set up variables
Dim multiple As Integer
Dim answers(12) As Integer 'Array of 12 numbers

'Get Multiplier from user
Call GetValue(multiple)
'Calculate Answers
Call CalcAnswer(answers(), multiple)
'Display table
Call DisplayTable(answers(), multiple)
End Sub


Private Sub GetValue(ByRef intvalue As Integer)
intvalue = InputBox("Please enter the value")
End Sub


Private Sub DisplayTable(ByRef answers() As Integer, ByVal multiple)
Dim counter As Integer
Dim Answer As Integer

For counter = 1 To 12
lstOutput.AddItem multiple & " X " & counter & " = " & answers(counter)
Next
End Sub


Private Sub CalcAnswer(ByRef answers() As Integer, ByVal multiple)
Dim counter As Integer

For counter = 1 To 12
answers(counter) = multiple * counter
Next
End Sub

Also

The game.