|
![]() |
![]() |
![]() |
![]()
Example:
Private Sub Form_Load()
Dim intNum As Integer
intNum = 1
MsgBox "The value before call” & intNum
AddOne intNum ‘this is the “call”
MsgBox "The value after call " & intNum
End Sub
Now lets write the subroutine:
Sub AddOne(ByVal intN As Integer)
intN = intN + 1
End SubResults:
The procedure leaves intNum unaffected
Example:
Now a simple change
Sub AddOne(ByRef intN As Integer)
intN = intN + 1
End Sub
Results:
Note the different results!
![]()
Global
- Defined in General Declarations
- Known throughout form
Local
- Defined in subroutine
- Only known in that subroutine
![]()
Global
- Born when program compiled
- Die when program ends
Local
- Born when subroutine called
- Die when subroutine concludes
![]()
![]()
Chapter 7 excercises 1, 2, 3, 4.
![]()