I did not think Shared could be used in Subroutines but it appears so...
Anyway the 4th method makes sense to me because a, b are default single as "Shared" in the 4th Method of Sub
Here is a further mod to show what I see:
Anyway the 4th method makes sense to me because a, b are default single as "Shared" in the 4th Method of Sub
Quote:SHARED a, b, c AS INTEGER ' only the value of 'c' is passed, 'a' and 'b' are zero.
Here is a further mod to show what I see:
Code: (Select All)
Dim As Integer a, b, c
a = 10
b = 20
c = 30
Mysub
Print a, b, c
Sub Mysub ()
'---------------
' ** Method 1 ** ------------> ** THIS WORKS **
'---------------
'SHARED AS INTEGER a, b, c ' all SHARED on a single line
'---------------
' ** Method 2 ** ------------> ** THIS WORKS **
'---------------
'SHARED a AS INTEGER ' all SHARED on a separate line
'SHARED b AS INTEGER
'SHARED c AS INTEGER
'---------------
' ** Method 3 ** ------------> ** THIS WORKS **
'---------------
'SHARED AS INTEGER a, b ' two different SHARED alternatives
'SHARED c AS INTEGER
'---------------
' ** Method 4 ** ------------> ** THIS DOES -NOT- WORK **
'---------------
Shared a, b, c As Integer ' only the value of 'c' is passed, 'a' and 'b' are zero.
'-----------------------------------------------------------------------------------
' Method 4 is not a valid alternative to SHARED listed in the Wiki and should
' therefore not work. However, I would think an error would be generated in the IDE
' or at least at run-time when SHARED is attempted to be used in this manner?
'-----------------------------------------------------------------------------------
a = 1.111: b = 2.222
Print a, b, c
End Sub
b = b + ...